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

Joe han
  • 171
  • 11
  • 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. – Karl Knechtel Dec 25 '22 at 00:48

2 Answers2

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)
cengineer
  • 1,362
  • 1
  • 11
  • 18
1
import display
a = int(input('1st number:'))
b = int(input('2nd number:'))
c = a + b
display.display1(c)

.

def display1(c):
    print(c)
Alaa Aqeel
  • 615
  • 8
  • 16