Reputation: 3801
I realize this code really makes no sense, but I am just practicing :)
Basically want I want to do is if the user enters a blank name for birthdays, I want it to jump to the savings loop and run through that code.
I am realizing though that the following is not correct:
self.savings()
Any ideas?
Thanks
birthdays = {'Alice': 'Apr 1', 'Bob': 'Dec 12', 'Carol': 'Mar 4'}
while True:
print('Enter a name: (blank to quit)')
name = input()
if name == '':
self.savings()
if name in birthdays:
print(birthdays[name] + ' is the birthday of ' + name)
else:
print('I do not have birthday information for ' + name)
print('What is their birthday?')
bday = input()
birthdays[name] = bday
print('Birthday database is updated')
savings = {'401k': '100.00', 'RothIRA': '500.00', 'Savings': '350.00'}
while True:
print('Enter an account: (blank to quit)')
money = input()
if money =='':
break
if money in savings:
print((savings[money] + ' is the total amount in your ') + money)
else:
print('I do not have savings info for ' + money)
print('How much money is in this account?')
acct = input()
savings[money] = acct
print('Savings database is updated')
print(savings)
Upvotes: 0
Views: 60
Reputation: 28
Instead of self.savings()
in
if name == '':
self.savings()
couldn't you you use break
to leave the while loop immediately? And then it should move on to the next loop.
...I'm pretty sure that would work.
Upvotes: 1