I need to check if the user has entered a value in the Name and Number string and, if not, give them the option to automatically re-enter the value, while avoiding breaking the code due to errors. Also, immediately check whether the name was entered with a capital letter (or automatically replace the first letter with a capital letter).
But I'm stuck at the very beginning because even though the name and number values have been entered, my loop doesn't break and ask for the values again. But I need it to take the user back to the menu after successful input.
Here is my piece of code:
telephone_dict = {"Nino":"0123", "Nick": "0234", "Jake":"0345"}
menu = 1
while menu !=0:
print("""
1. Add new names and telephone numbers to the dictionary
2. Delete telephone numbers from the dictionary by the given name
3. View the entire telephone dictionary (names and numbers)
4. View/Search for a single entry by name
5. Save Data
6. Load Data
0. Exit
""")
menu = int(input("Choose menu option: "))
if menu == 1:
while True:
try:
name =(str(input("Enter a name: ")))
num =input("Enter a number: ")
telephone_dict[name] = num
if name == '':
print("You did not enter anything, please, try again")
elif num == '':
print("You did not enter anything, please, try again")
except ValueError:
print("Invalid Input")
continue