I have this code:
import sys
x=0
y=0
z=0
def Total(a,b,c):
a=1
b=2
c=a+b
return c
Total(x,y,z)
print(z)
I initially anticipated a result of 3, but unfortunately, the outcome is still 0. How can I resolve this issue?
I have this code:
import sys
x=0
y=0
z=0
def Total(a,b,c):
a=1
b=2
c=a+b
return c
Total(x,y,z)
print(z)
I initially anticipated a result of 3, but unfortunately, the outcome is still 0. How can I resolve this issue?
You need to assign the returned value of Total to z. Right now you aren't doing anything with the returned value of Total(x,y,z).
x=0
y=0
z=0
def Total(a,b,c):
a=1
b=2
c=a+b
return c
Total(x,y,z) # Total returns 3, but the value is not assigned to anything
print(z) # Z is still 0
What you need is:
x=0
y=0
z=0
def Total(a,b,c):
a=1
b=2
c=a+b
return c
z = Total(x,y,z) # Assign the returned value of Total (which is 3) to z
print(z) # Print z (which is 3) out
try this it gives me 3 because the a and b have been set to x and y the doesnt need to be there
import sys
x=0
y=0
z=0
def Total(a,b):
a=1
b=2
c=a+b
print(c)
Total(x,y)
also why u usin sys