Python misbehaving

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
no link
<In what way does your code behave incorrectly? Include ALL error messages.>
something about the parentheses?
if input == (“Good, thank you”)
SyntaxError: invalid syntax
<What do you expect to happen instead?>
It is supposed to run correctly

```python

def main():
print(“How’s your day?”)
if input == (“Good, thank you”)
print(“No problem”)
elif input == (“Good, thank you!”)
print(“No problem!”)
elif input == (“It was great!”)
print(“Oh, really? Good for you!”)
elif input == (“It was great, thank you!”)
print(“Good to hear!”)
elif input == (“It was great”)
print(“Oh, really? Good for you!”)
elif input == (“It was great, thank you”)
print(“Good to hear!”)
else input == (“see you later!”)
main()
input(“Press Enter or Return to end!”)

<do not remove the three backticks above>

what do you mean the whole condition?

thank you! but now it says something about the t in input (line 15)

This is comparing a variable named input to a string, but

this is calling a function called input

Which was it supposed to be?

else doesn’t take a condition.

ohhhh right! thanks a lot!!!

wait, i changed that to else print(“see you later!”), and it selects the end of print again.

i replaced print with input, same thing…

spaces has nothing to do with it…

Try:
→ giving main() a parameter of input.
→ putting a colon : at the end of each line starting with if, elif or else.
→ changing the else part to:

else:
    input = "See you later!"

→ calling the main() function with a parameter (for example main("Good, thank you"))
→ removing the input(...) at the end.

thanks! now it displays though

do i have to make it wait?

Try:

def main(input):
    print("How's your day?")
    if (input == "Good, thank you"):
        print("No problem")
    elif (input == "Good, thank you!"):
        print("No problem!")
    elif (input == "It was great!"):
        print("Oh, really? Good for you!")
    elif (input == "It was great, thank you!"):
        print("Good to hear!")
    elif (input == "It was great"):
        print("Oh, really? Good for you!")
    elif (input == "It was great, thank you"):
        print("Good to hear!")
    else:
        print("See you later!")
main("Good, thank you") #should print "No problem"

HERE!!!
HERE!!!
HERE!!!
HERE!!!
i can’t post that many comments, so im editing, but thanks, it works.

It should only print once, but it might show it twice because of the way that the console returns things. Does it pass?

With all the possible variables one could use, is it really necessary to use a reserved word? Why confuse yourself or your reader?

user = input('...")

If you want to allow user input, then do it before the function call, not after. Code executes top down.

def main(us):
    # code

user_input = input(" ... ")
main(user_input)

Since this is Python 3 I’m going to assume this is not a lesson. Moved to Corner Bar.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.