0
is return not working on sololearn?
return doesn't work on sololearn? i was coding and my code was for testing if this app is good since i just started using sololearn, it was a simple code but it gave no output: def age(s, a): n=0 while s < a: n = n+1 s += 1 return n age(2004, 2022) but it had no ouput...
7 Answers
+ 5
Return is working but now you have value and you are not doing anything with this value
So use something to show output to console like print()
https://code.sololearn.com/cdfZLKx5Qd3O/?ref=app
+ 4
G'day Rayan
"to test if SoloLearn was good..." Yep. But mainly for the community. We help each other and sometimes have some cool ideas to share. Check out some of the "code bits" sorted by Python & most popular .
or some of the amazing stuff Brian does...https://code.sololearn.com/choN9R3QBDbd/?ref=app
+ 2
Rayan ,
can you please explain what you are calculating? what is the task description?
thanks!
+ 2
Rayan ,
ok - thanks!
+ 1
Lothar this is my code updated:
def age(s, a):
n=0
while s < a:
n = n+1
s += 1
return n
y = int(input())
Y = int(input())
age(y, Y)
this code gets how old are you compared to the year you are born untill the current year, i could also just do this:
def age(s, a):
return a - s
y = int(input())
Y = int(input())
age(y, Y)
but as i said, i am new here and i did this random code to test if sololearn was good or just a python file saver to later send it to your pc for example and use the code there..
0
PanicS but when i normally code on google collab, this code will return the value with return, and if i put print on while it will print all the values that had been writing in the data all along s < a... so here it's different then
0
i actually corrected my code later