What's wrong with these codes? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: What's wrong with these codes? (/thread-35391.html) |
What's wrong with these codes? - bouraque7878 - Oct-27-2021 It doesn't work. What's wrong? list1 = [1, 1] i = 2 while True: terim = list1[i - 1] + list1[i - 2] list1.append(terim) terim = str(terim) for x in terim: if len(terim) == 100: break i += 1 print(terim) RE: What's wrong with these codes? - Axel_Erfurt - Oct-27-2021 Do not post images, use the python button and insert your code . RE: What's wrong with these codes? - Yoriz - Oct-27-2021 Not sure what your trying to do but the print is unreachable, it's an infinite while loop, the break only break the for loop. RE: What's wrong with these codes? - Gribouillis - Oct-27-2021 If the for exits, the i += 1 will kill the while loop by raising IndexError at next iteration. RE: What's wrong with these codes? - bouraque7878 - Oct-27-2021 I solved it. The for loop shouldn't be there. Thanks for replies. |