Hey, im very new to python(just 2 Weeks). I write a new programm where a user typer can watch his contact informations and edit them (i learn Lists at the moment)
Here is the code (dont kill me its not finished but i want to fix the problem than i do the rest)
end = " "
l = ["Anton", "Lea", "Josef"]
second_name = ["Himalaya", "Bertel","Stalin"]
age = [23, 40, 102]
counter = 0
change_input = ["Pease Type in the new First Name", "Pease Type in the new First Name", "Please Type in the new Age"]
change_out = ["was successfully changed"]
option = " "
while option != 3:
x = ["1 == Show Contacts\n", "2 == Add Contact Information\n", "3 == edit Contact Informations\n"]
print(x)
option = input("please choose an option:\n")
if int(option) == 1 or int(option) == 2 or int(option) == 3:
print(l)
show_contact = int(input("Which Contact Informations do you want to look like?\n"))
if show_contact == 1:
print(l[0], second_name[0], age[0], " Years old")
elif show_contact == 2:
print(l[1], second_name[1], age[1], " Years old")
elif show_contact == 3:
print(l[2], second_name[2], age[2], " Years old")
edit = int(input("Do you want to edit the contact informations?\nPress 1 for yes 2 for no\n"))
if edit == 1:
what = ["1 == First Name\n", "2 == Last Name\n", "3 == Age\n"]
print(what)
edit_what = int(input("Which Informations do you want to edit?"))
if edit_what == 1:
l[0] = input("Pease Type in the new First Name")
print("Name successfully changed")
input("please confirm with press any button")
elif edit_what == 2:
second_name[1] = input("Pease Type in the new Last Name")
print("Name successfully changed")
input("please confirm with press any button")
elif edit_what == 3:
age[1] = int(input("Please Type in the new Age"))
print("Age successfully changed")
input("please confirm with press any button")
else:
print("Dont understand. Please try again")
> Blockquote
# Codeblock for later
while end != 1:
a = input("Please type in the name of the Person that you want to add to the list\n")
l.append(a)
sn = input("type in the last name")
second_name.append(sn)
b = int(input("How old is the Person?\n"))
age.append(b)
print("You got", (l[-1]), second_name[-1], "at the age of", age[-1], "successfully addet.\n "
"Changes are saved!")
print(l)
end = input("to close press 1 for continue press 2")
if int(end) == 1:
print("closed")
break
else:
continue
So the Problem is: For example he choose at show_contact number 1.
Than i have to type all options for every contact but
I dont want to type in the same 3 Times
Is there a way just type it in 1 time and then put it in if i need it? Hope you understand. If not just ask me.