0

I am a beginner in Python and I am trying to write a program that is essentially a "fortune teller" using functions. I seem to be having an issue when calling a function get_today() which is written to take an input form the user for the day of the month, and return it as an integer.

However when I call on the function I am prompted with an error that goes:

TypeError: get_today() missing 1 required positional argument: 'd'

I've tried playing around a bit and cannot figure out what this means. Here is the main function:

def main():

    print("Welcome​ ​to​ ​Madame​ ​Maxine's​ ​Fortune​ ​Palace. Here,​ ​we​ ​gaze​ ​deeply into​ ​your​ ​soul​ ​and​ ​find​ ​the secrets​ ​that​ ​only​ ​destiny​ ​has​ ​heretofore​ ​known!")
    print("")
    print("The​ ​power​ ​of​ ​my​ ​inner​ ​eye​ ​clouds​ ​my​ ​ability​ ​to​ ​keep track​ ​of mundane​ ​things​ ​like​ ​the​ ​date.")
    d = get_today()
    print("Numerology​ ​is​ ​vitally​ ​important​ ​to​ ​fortune​ ​telling.")
    b = get_birthday()

    if(d >=1 and d <= 9):
        print("One more question before we begin.")
        a = likes_spicy_food()
        print("I will now read your lifeline")
        read_lifeline(d,b,a)
    if(d >= 10 and d <= 19):
        print("I will now read your heartline.")
        read_heartline(d,b)
    if(d >= 20 and d <= 29):
        print("I need one last piece of information.")
        m = get_birthmonth()
        read_headline(b,m)

    if(d == 30 or d == 31):
        print("Today is a bad day for fortune telling.")

        print("These insights into your future are not to be enjoyed or dreaded, they simply come to pass.")
        print("Good day.")

main()

This issue will likely repeat when the second function get_birthday() is called, which asks the user for the day of the month they were born.

Here is the code snippet for get_today():

def get_today():

        x = int(input("Tell​ ​me,​ ​what​ ​day​ ​of​ ​the​ ​month​ ​is​ ​it​ ​today:​"))

        return x

Help would be massively appreciated!

3
  • 1
    For one thing, the function get_today takes an argument but when you all it in main, you don't give it any arguments. It looks like you don't actually need the argument for get_today, so remove the d in def get_today(d): Commented Oct 8, 2017 at 2:48
  • Well when you're calling get_today you're not passing an argument to it for a start... Commented Oct 8, 2017 at 2:49
  • removing the d prompted me with a new error TypeError: get_today() missing 1 required positional argument: 'd' Commented Oct 8, 2017 at 3:10

1 Answer 1

1

When I run this code as is, it doesn't give me your error. However, when I run this code with d = get_today() as d = get_today(d) under main, I get the error you're getting.

When you call a function, what goes between the parentheses is what gets passed into the function. Since you don't have d assigned yet, you can't pass it in. In addition, your function doesn't need variables to be passed in since all it is is the user input.

Try this:

def main():
    #code
    d = get_today()
    #more code

def get_today()
    #the function with return statement

main()
Sign up to request clarification or add additional context in comments.

7 Comments

removing the d prompted me with a new error TypeError: get_today() missing 1 required positional argument: 'd'
Did you remove d from def get_today()?
Yes, I will post what the edit looks like in the original question. @Brandon Molyneaux
And I'm presuming you removed it from main as well?
Yes, I did indeed.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.