Home > Blockchain >  Why is Ergebniss1 "none"
Why is Ergebniss1 "none"

Time:10-23

The code from my project

The output: How long is the lasagna in the oven: 10 30 How many layers do you want to make: 20 40 None

My question is why is the Ergebniss1 a "none" and not the number from the function?

CodePudding user response:

print() always returns None.

So you'd want to write your code like this:

Ergebniss1 = Expected_Bake_Time - Minutes_Baked
print(Ergebniss1)

CodePudding user response:

You are trying to print a print statement, a cleaner approach would be to return values from the function and then print them:

Expected_Bake_Time = 40
Layers_Time = 2

def Bake_Time_Remaining(Minutes_Baked, Expected_Bake_Time):
    return Expected_Bake_Time - Minutes_Baked

Ergebniss1 = Bake_Time_Remaining(int(input("How long is the lasagna in the oven: ")), Expected_Bake_Time)
print(Ergebniss1)

def Prep_Time_In_Minutes(Layers, Layers_Time):
    return Layers * Layers_Time

Ergebniss2 = Prep_Time_In_Minutes(int(input("How many layers do you want to make: ")), Layers_Time)
print(Ergebniss2)
  • Related