Just started learning Python, part of my script isn't working. Can someone help me UNDERSTAND why?

I’m just starting to learn Python today and I typed up a basic script (It doesn’t completely work). Here it is.

name = input('Hi! What is your name?\n')
print('Hi, %s.' % name)

mood = input('How are you doing today?\n')
def mood(n):
  if n == 'Good':
    print ('Good to hear that')
  if n == 'Bad':
    print ('Sorry to hear that')

Anyways, the second question in it (How are you doing today?) doesn’t respond and I don’t understand why. Can someone help explain to me why it didn’t work rather than just give a revised version of the script?:slightly_smiling_face:

Here’s the script ran step by step:

  1. Part%201

  2. Part%202

  3. Part%203

Your mood() function is never called.

moodString =  input('How are you doing today?\n')

Also you have a return statement be for the print statement for the response, meaning that the function will end before it responds.

def mood(n):
    if n == 'Good':
        print('Good to hear that') # print the respose
        return # exit the function
    ... #Rest of the code

Hope this helps :grin:

1 Like