+ 1
Why doesnât this work?
https://sololearn.com/compiler-playground/catTaw2QOpSY/?ref=app
8 Answers
+ 1
Because you aren't calling the defined function volume
+ 3
Muna Orah
1. you don't need arguments, since the inputs are inside the function already.
2. you are multiplying strings. convert to int.
3. as Luo Shenshi said, you did not call the function. you only defined it.
4. you need to print the result in order to actually see it.
def volume(): # no need for arguments
# convert inputs to int
a = int(input("enter the length of the fish tank: "))
print(a)
b = int(input("enter the depth of the fish tank: "))
print(b)
c = int(input("enter the height of the fish tank: "))
print(c)
return (a * b * c) / 1000
v = volume() # call the function, assign to variable
print(v) # print to see the result
'''
sample Sololearn input:
2
4
6
submit
'''
+ 2
Correct code:
#fish tank volume problem.
# main program
def volume(a,b,c):
return (a * b * c) / 1000
print(volume(10, 20, 30))
+ 2
Luo Shenshi
right...đ I edited my reply because I was worried the function call part would be mixed up with the print result step. I did not remember to change the original print(volume()) part. Thanks for the reminder. đ
I corrected my post above.
+ 1
Bob_Li no need to print volume if you can print v
+ 1
No invocation to the function defined.
0
n
0
a,b,c