def x1():
y = input("Input pet here: ")
if y == "pet":
return True
else:
return False
x1()
def x2():
y = input("Input pet here: ")
if y == "pet":
print(y)
else:
print("not a pet")
x2()
Output: C:\Users\jiraf\AppData\Local\Programs\Python\Python39\python.exe "C:/Users/jiraf/OneDrive/Documents/Grzegorz/Programowanie/Python/kurs/1.02/Wykład 1.8 Funkcje (definiowanie, argumenty).py"
Input pet here: shit Input pet here: shit not a pet
Process finished with exit code 0
I have tried with many easy functions that simply should return something
I have no idea why is that.
return
does not print to output, it just returns function result. You may have seen this printing when using python shell
as it does print result for some needed reasons.
For your 1st function to print you must print the called function like this
print(x1())