Why this is showing error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why this is showing error?

while True: x=input('Enter Table: ') y=x*10 numbers = list(range(eval(x), eval(y), eval(x))) print(numbers)

20th Jun 2019, 3:54 PM
Dark Warrior
Dark Warrior - avatar
5 Answers
+ 1
eval() is used to evaluate a string like an expression. You can't use it on an arbitrary variable There's no need to use eval() in your code, but if you want to use it, try something like numbers = eval(f'range({x}, {y}, {x})')
20th Jun 2019, 3:57 PM
Anna
Anna - avatar
+ 1
Those are normally not good signs 👆
20th Jun 2019, 4:03 PM
Anna
Anna - avatar
+ 1
But it will ask for input after every loop
20th Jun 2019, 4:54 PM
Dark Warrior
Dark Warrior - avatar
0
It is saying memory error on code playground On IDE the python console just vanished and window is closed
20th Jun 2019, 3:59 PM
Dark Warrior
Dark Warrior - avatar
- 1
while True without break means infinite loop.
20th Jun 2019, 4:29 PM
Choe
Choe - avatar