Eliminate duplicate input call
- We can use the
while True
construct to avoid this duplication.
while True:
id_str = input("Type in your ID: ")
if len(id_str) == 9:
break
print("Your ID is " + id_str)
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
while True
construct to avoid this duplication.while True:
id_str = input("Type in your ID: ")
if len(id_str) == 9:
break
print("Your ID is " + id_str)