0
Are parameters and variables same?
In the code below, I tried to define two parameters 'x' and 'y', where the user will input the value of numbers ( just like normal variables, but instead directly as arguments) i.e. when I call the function for user input, it shows the 'x' is not defined, but I have defined it as : int(input(enter a number: )). Could someone explain? Thank a ton :) https://code.sololearn.com/c4l1m7kU8VCa/?ref=app
3 Respuestas
+ 3
Since you define the variables inside the function, there is no need for parameters.
Try:
def func():
#your function
func()
If you want to use parameters:
def func(x,y):
if x > y:
print(x)
.......
func(3,5)
Since you define x as the first digit and y as the second, when you call the function with x and y replaced with values they replace them in the function
+ 3
Why not try like this
Fun(x=int(input()), y=int(input()))
+ 2
Understood ! Thanks a lot !