Aug-19-2018, 11:27 AM
Hello every one, im a newbie python programmer.I was just trying few codes the other day and came across a simple code, unfortunately its stuck in an infinite loop. I tried to figure it out but for no avail.It is basically a Score storing code which shows , adds , removes,sorts and exits based on users will. Down is the code im trying to run but the infinite loop problem arises.
-----------------------------------------------------------------------------------------------
Oh and the indentations are proper, its just that when i post the thread, it automatically cancel out unwanted space.
-----------------------------------------------------------------------------------------------
scores = [] choice = None while choice != 0: print(""" \t\t High Score 0 - Exit 1 - Show Scores 2 - Add scores 3 - Remove a Score 4 - Sort scores """) choice = input("Choice: ") #Programe ends when user enters '0' if choice == 0: print ('Good Bye') #All the stored High scores are printed elif choice == 1: print ('High Score') for score in scores: print (score) #Lets user enter the High Score elif choice == 2: score = int(input("What score did you get")) scores.append(score) #Removes a Score elif choice == 3: score = ("Remove which score?") if score in scores : score.remove(score) else: print(score,'isnt in the score list')-------------------------------------------------------------------------------------------
Oh and the indentations are proper, its just that when i post the thread, it automatically cancel out unwanted space.