Duplicate input call with loop
- A
whileloop would be a better solution. - This works, but now we have duplicated the
inputcall and the text is different in the two cases. DRY - We can't remove the first call of
inputas we need theid_strvariable in the condition of thewhilealready.
id_str = input("Type in your ID: ")
while len(id_str) != 9:
id_str = input("Type in your ID")
print("Your ID is " + id_str)