0

I have this program:

import display
a = int(input('1st number:'))
b = int(input('2nd number:'))
c = a + b
display.display1

and the other with the name 'display':

def display1():
    print(c)

It will come out :

NameError: name 'c' is not defined

how do I define the 'c' to find the total for a and b?. Thanks

1
  • Note to self: the canonical duplicate here addresses the opposite problem (getting the information out of the function, rather than in). I will need to write an artificial canonical for this, probably. Although this is still not a good signpost. Commented Dec 25, 2022 at 0:48

2 Answers 2

1

You need to pass the parameter c to the function display1.

So your display1 function should be like as follows

def display1(c):
    print(c)

And while calling you need to give c to display1 function as a parameter as follows

display.display1(c)
Sign up to request clarification or add additional context in comments.

1 Comment

thanks for the help...works
1
import display
a = int(input('1st number:'))
b = int(input('2nd number:'))
c = a + b
display.display1(c)

.

def display1(c):
    print(c)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.