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 the id_str variable in the condition of the while already.
examples/loops/duplicate_input_call.py
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)