mememan mememan - 3 months ago 16
Python Question

an if Statement inside an if Statement?

FarmGround=input("Do you want to pat the animal? ") #this is the input
if FarmGround==("Yes") or FarmGround==("yes"): #this is if
print("You patted the animal") #print statement if you patted the animal it will go onto the next if statement
if print=("You patted the animal"):
elif FarmGround==("No") or FarmGround==("no"): #this is elif
print("You didn't patt the animal and it is triggered")


undescribed image

Answer

Your code is quite clear. What I understand is you want to ask another question if animal is patted.

FarmGround=input("Do you want to pat the animal? ") #this is the input

if FarmGround=="Yes" or FarmGround=="yes":  #this is if
    print("You patted the animal") 

    holy_field = input("Did you clear the field?") 
    if holy_field.lower() == "yes":
         print("Do something else. Don't look at me.") 
    else: 
         print("When are you going to do it ?")          
elif FarmGround== "No" or FarmGround== "no": #this is elif
    print("You didn't patt the animal and it is triggered")
Comments