You did not enter a number during input, instead you simply pressed enter (and got back the empty string). You need to add code to handle the situation where a user enters invalid input, in Python, this is performed with a try-except
where you specify the error you're expecting ValueError
in the except
clause:
def liste_pop():
print(liste)
while True:
try:
pop = int(input('remove = Enter um das letzte Element der Liste auszugeben + entfernen oder die Position eingeben'))
break
except ValueError as e:
print("Only numbers accepted")
liste.pop(pop)
Of course, this has an additional issue, what if a user enters a number outside the accepted range? An IndexError
is raised; you'll need another try-except
for that (I'll let you handle it on your own.)