Duplicate input call
- Ask the user what is their ID number.
- Check if it is a valid ID number. (To make our code more simple we only check the length of the string.)
- Ask again if it was not a valid number.
examples/loops/duplicate_input_call_with_if.py
id_str = input("Type in your ID: ") if len(id_str) != 9: id_str = input("Type in your ID") print("Your ID is " + id_str)
- Realize, that if the user types in an incorrect string for the 2nd time, our code does not check it.