0

Booleans to numbers

""" Write a code that takes two whole number as input and lists all the even numbers between the interval of the two inputs.""" num1=int(input()) num2=int(input()) for i in range(num1, num2): even = i %2 == 0 print(even) I'd like to ask what lesson has the clue to list the actual numbers, not just true/false? Thank you!

27th Jan 2022, 8:50 AM
Kajtár László
Kajtár László - avatar
4 Antworten
+ 1
#Use 'if' condition, num1=int(input()) num2=int(input()) for i in range(num1, num2): if i %2 == 0: print(i) // Kajtár László edit]: you can do one more thing,in this line write 2 after num2 like this: for i in range(num1, num2, 2): it will work too!
27th Jan 2022, 8:54 AM
NEZ
NEZ - avatar
+ 1
I see "Booleans to numbers" in title. In Description I see a question about filtering even numbers within range. Am I the only who got lost trying to relate the title and the Description???
27th Jan 2022, 10:47 AM
Ipang
+ 1
When I run the code it outputs True False True False... according to if it's even or odd, not the numbers themselves. Sorry if it's misleading! :/
27th Jan 2022, 11:12 AM
Kajtár László
Kajtár László - avatar
0
Epic! Thank you! Shame I didn't tought about that...
27th Jan 2022, 8:57 AM
Kajtár László
Kajtár László - avatar