0
def name_function():
    firstName = input("Enter your first name: ")

name_function()
print("My name is " + firstName)

the expected output is the name

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
Lamort102
  • 1
  • 2
  • Your function `name_function()` reads the name from the user into `firstName` then discards the result (it doesn't return its value). Your code as show should yield an error on the `print` statement since `firstName` isn't defined at that point. – lurker Jun 07 '20 at 23:07
  • Yes thank you so much that helps a lot now that I have an example thanks a lot!! – Lamort102 Jun 07 '20 at 23:23

1 Answers1

0
def name_function():
    firstName = input("Enter your first name: ")
    return firstName # forgot to add this

firstName = name_function() #forgot to assign value to firstName
print(firstName)
tersrth
  • 861
  • 6
  • 18