Calling one method from another method in Python

JD2775

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)
CCramer

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Calling a method from another method

From Javascript

Calling a method from another method in the same class

From Javascript

Calling one prototype method inside another in javascript

From Java

Calling one method from another within same class in Python

From Java

Calling method of Another class from run() method

From Java

calling another method from the main method in java

From Java

Calling a method in one fragment from another

From Dev

Python Inherit from one class but override method calling another class?

From Dev

Django - Calling one class method from another in Class Based View

From Dev

Calling a method from inside a thread to another class in python pyqt

From Dev

Calling a method in thread from another thread, python

From Dev

Calling an instance declared in one method from another method

From Dev

Calling a class method from another class method in Python 2.7

From Dev

Undefined Method - Calling a class in one file from another

From Dev

Trouble calling one method into another

From Dev

calling method from one controller to another controller in angular js

From Dev

Java: Calling variables of user input from one method to another

From Dev

Calling an impl method from another impl method

From Dev

Python: Calling a decorator method from another class

From Dev

Exiting from a Method by calling another Method

From Dev

Calling a method from one class in another class

From Dev

Calling Test Method from another Test Method

From Dev

Calling variables from one method to another in Python

From Dev

Calling a list from one method to another in the same class in Python

From Dev

Kivy - Calling a pulsing method from one class to another

From Dev

python, calling a method from another class

From Dev

calling an object method from another method not working

From Dev

Using variable from one method in another method in Python

From Dev

Calling Javascript prototype method from another method

Related Related

  1. 1

    Calling a method from another method

  2. 2

    Calling a method from another method in the same class

  3. 3

    Calling one prototype method inside another in javascript

  4. 4

    Calling one method from another within same class in Python

  5. 5

    Calling method of Another class from run() method

  6. 6

    calling another method from the main method in java

  7. 7

    Calling a method in one fragment from another

  8. 8

    Python Inherit from one class but override method calling another class?

  9. 9

    Django - Calling one class method from another in Class Based View

  10. 10

    Calling a method from inside a thread to another class in python pyqt

  11. 11

    Calling a method in thread from another thread, python

  12. 12

    Calling an instance declared in one method from another method

  13. 13

    Calling a class method from another class method in Python 2.7

  14. 14

    Undefined Method - Calling a class in one file from another

  15. 15

    Trouble calling one method into another

  16. 16

    calling method from one controller to another controller in angular js

  17. 17

    Java: Calling variables of user input from one method to another

  18. 18

    Calling an impl method from another impl method

  19. 19

    Python: Calling a decorator method from another class

  20. 20

    Exiting from a Method by calling another Method

  21. 21

    Calling a method from one class in another class

  22. 22

    Calling Test Method from another Test Method

  23. 23

    Calling variables from one method to another in Python

  24. 24

    Calling a list from one method to another in the same class in Python

  25. 25

    Kivy - Calling a pulsing method from one class to another

  26. 26

    python, calling a method from another class

  27. 27

    calling an object method from another method not working

  28. 28

    Using variable from one method in another method in Python

  29. 29

    Calling Javascript prototype method from another method

HotTag

Archive