Duplicate input call with loop
- A
while
loop would be a better solution. - This works, but now we have duplicated the
input
call and the text is different in the two cases. DRY - We can't remove the first call of
input
as we need theid_str
variable in the condition of thewhile
already.
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)