-2

Code:

print("Starting...")

def test():
    notare = input()
    bote()

def bote():
    if notare == "a":
        print("b")
    else:
        print("c")

test()

Error:

Traceback (most recent call last):
  File "test.py", line 13, in <module>
    test()
  File "test.py", line 5, in test
    bote()
  File "test.py", line 8, in bote
    if notare == "a":
NameError: name 'notare' is not defined
chepner
  • 497,756
  • 71
  • 530
  • 681
  • Correct; `notare` is not defined. Is your question *why* it is not defined, or do you want some workaround so that it *is* defined in `bote`? – chepner Sep 27 '19 at 15:13
  • The problem is that you have not defined what `notare` is in your `bote` function. You need to pass it as a variable to bote. Also, this is a very basic question and shows no effort on your part. Just pasting your code and error message won't make people very happy to help you.. – Alexander Rossa Sep 27 '19 at 15:14

1 Answers1

0

python wont know the function exists... Python executes in a orderly fashion... Meaning you have to declare the function before you can call it...

So to your problem.. Try moving the function above the function calling it..

Like so

print("Starting...")

def bote(notare):
    if notare == "a":
        print("b")
    else:
        print("c")

def test():
    notare = input()
    bote(notare)


test()
Yatish Kadam
  • 454
  • 2
  • 11