0

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)
asked Jul 21, 2017 at 2:48
3
  • 1
    Your question is unclear. Your code doesn't define any functions or methods. I think you need to read about defining functions in your textbook or tutorial. Commented Jul 21, 2017 at 2:53
  • Use definitions? Commented Jul 21, 2017 at 2:53
  • @PM2Ring you are correct, I don't actually have any functions or methods. Just 2 dictionary variables. I wasn't looking at this clearly. Thanks Commented Jul 21, 2017 at 2:58

1 Answer 1

1

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.

answered Jul 21, 2017 at 2:54
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.