I am new to programming, and I am trying to trying to solve this for my assignment(instructions below), but I have few quick questions:
- is there any way to simply or condense some of these lines, i feel like I am rendundantly printing when I dont know if there is another way I can have it all in one print line, for instance:
print ("which state capitals do you want to know: ")
print (list(state_dictionary.keys()))
is there a way that can be one print statement?
def state_capitals():
state_dictionary= {"New Hampshire":"Concord", "Massachusetts": "Boston", "Maine": "Albany",
"Vermont": "M", "New York": "Albany"}
i=0
while i <= (len(state_dictionary)):
print ("which state capitals do you want to know: ")
print (list(state_dictionary.keys()))
getcapital= input("enter state: ")
print(state_dictionary[getcapital])
state_dictionary.pop(getcapital)
more= (input("Do you want to know the capital of any more states? Please enter Yes/No: "))
if more == "yes":
if bool(state_dictionary):
continue
elif not bool (state_dictionary):
print ("i am out of states")
break
elif more == "no":
break
state_capitals()