why if I am adding values to a list and a type error occurs the last value it prints twice | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why if I am adding values to a list and a type error occurs the last value it prints twice

https://code.sololearn.com/cg9zkRMqxPqK/?ref=app

17th Jun 2022, 6:34 AM
Alejandro47
Alejandro47 - avatar
2 Answers
+ 1
If an error occurs the code statement will jump into the except clause without reassigning x to a new value… In the next iteration of the loop when x is added to the list, the old value is added (again) To change that, you should reorder the input meachanism and the list.append, such that there will only be something appended to the list, if a new valid input was received
17th Jun 2022, 8:19 AM
Alexander Thiem
Alexander Thiem - avatar
0
What are you trying to do??
17th Jun 2022, 7:26 AM
JOKER
JOKER - avatar