0

Basic python difficulty

Just started and was playing with functions and if statements but I can’t get it to return true, it keeps just returning with 8. ********************** def f(x): print((x**2) + 4) x = 2 if f(x)==8: print("true") **********************

7th Dec 2019, 6:46 PM
James Wilkinson
James Wilkinson - avatar
1 Antwort
+ 8
Hi, you need to return the calculation result (instead of printing it) done by the function back to the call of the function f(): def f(x): #print((x**2) + 4) return x**2 + 4 x = 2 if f(x)==8: print("true") # output: True
7th Dec 2019, 7:16 PM
Lothar
Lothar - avatar