+ 1
Could anyone help me ? I want the user to enter even or odd to get him the even or odd numbers of the limit. The code is given b
print(""". WARNING 1.odd 2.even """) even = 0 odd = 1 x = 2 i = int (input("Even or odd: ")) y = int (input("Limit of Number: ")) while i <= y : print(i) i = i + x print("Done")
1 ответ
+ 1
Why not to use list comprehension?:
flag = int(input("Even (1) or odd(0)?: "))
rng = int(input("Enter the range: "))
numbers = [x+flag for x in range(1, rng+1)if x&1]
print(numbers)