+ 1

Int or floating

Pseudocode: While x(which is an input) is NOT equal to any numbers(floating numbers INCLUDED) between 1-10: Do this My attempt was: While not x == range(1,11) but it doesnt work

15th Feb 2022, 2:54 PM
Lenoname
5 Réponses
+ 4
Yes
15th Feb 2022, 3:13 PM
Simba
Simba - avatar
+ 5
just to mention, that we can not use range() with float numbers, since range only generates integers: print(3.14 in range(1,11)) result is: False >> [Edited] : the following code enables you to use range(): inp = float(input()) if int(inp) in range(1,11): print(inp,"is in range") else: print("out of range")
15th Feb 2022, 3:34 PM
Lothar
Lothar - avatar
+ 2
not x in range()
15th Feb 2022, 2:57 PM
Simba
Simba - avatar
+ 2
Can i write While not 1 <= x <=10 ??
15th Feb 2022, 3:03 PM
Lenoname
+ 2
You can do while 1<=x<=10: print(True)
16th Feb 2022, 7:14 PM
Muhammad Abouraya
Muhammad Abouraya - avatar