Print some elements from input I am studying Python, so it is very easy task. I want to get best and most elegant way to solve each simple task.
The task is:


  Write a program that reads the integers from the console one number per line.
  For each entered number check:
  
  
  if the number is less than 10, skip that number;
  if the number is greater than 100, stop to read the numbers;
  
  
  Print all numbers that does not satisfy those two conditions.


lst = []
num = 0
while num &lt;=100:
    num = int(input())
    if num &gt; 100:
        break
    if num &gt;= 10:
        lst.append(num)

print('\n'.join(str(value) for value in lst))
Your code is pretty good. Change num &lt;=100 to True and remove the un-needed num out of the while loop, and it's good.
You should also expect user input to not be a number and handle it as you need.

Since comprehensions are a cleaner than map and filter, you may want to steer clear of them. Some people stick to never using them, I however use them if it makes the input clearer, such as map(str, user_input()).

You can then adjust your code slightly to get the iterative approach of:

list_ = []
while True:
    try:
        num = int(input())
    except ValueError:
        continue
    if num &gt; 100:
        break
    if num &gt;= 10:
        list_.append(num)


However, you may want a functional approach. This can be better as then you can pick and mix functions, but some don't like it as much.


Make an infinite generator, of user input.
itertools.takewhile the input is good.
Filter input.




def user_input():
    while True:
        yield input()

def to_int(numbers):
    for num in numbers:
        try:
            yield int(num)
        except ValueError:
            continue

nums = itertools.takewhile(lambda n: n &lt;= 100, to_int(user_input()))
print('\n'.join(str(n) for n in nums if n &gt;= 10))




Python is multi-paradigm, and so you can mix them. And so as-long as it works and is clear, it's fine. I personally would use:

def user_input():
    while True:
        try:
            yield int(input())
        except ValueError:
            continue

def filter_numbers(numbers):
    for num in numbers:
        if num &gt; 100:
            break
        if num &gt;= 10:
            yield num

print('\n'.join(str(n) for n in filter_numbers(user_input())))