0
What is wrong with this code ?
#List all the even numbers from an unknown value to 800 num = input('Enter a number') if num%2==0: even_nums = list(range(num, 801, 2)) print(even_nums) else: print('Enter a even number')
5 Antworten
+ 2
input() gets you the input as a String always even if you enter a number so you must explicitly convert the input to an int
num = int(input('Enter a number'))
+ 2
You are very welcome! ☺
+ 1
Now, if you also want to give the user the option to start with both an odd number you can use list comprehension like I did in the code below
https://code.sololearn.com/cFFHMPQu6qMQ/?ref=app
+ 1
thanks man
0
it's working now