ich bin gerade dabei mir einen "rechner" zu programmieren und es funktioniert bisher ganz gut nur bei der letzten antwort springe ich nach dem break in das if bzw else der vorigen schleife zurück.
ich habe vier while schleifen ineinander und bis auf die letzte funktioniert alles bestens. bei der letzten schleife wenn das if erfüllt wird sollte die schleife durch den break gebrochen werden nur springt es dann zum if/else der vorhergehenden while schleife zurück
was kann da nicht stimmen?
Code: Alles auswählen
print("What would you like to do today?")
##### RESTART at END #####
while 1==1:
print("Please choose [h] for humans and [f] for fruit flies for further options!")
q1=input("Your choice: ")
while (True):
if q1=="h":
print("humans it is!")
print("SORRY this function is not available yet! Please come back another time!")
break
#fruit flies
if q1=="f":
print("fruit flies it is!")
print("A wildtype fly with red eyes is crossed with a mutant fly with brown or white eyes")
print("Would you like to look at a cross with brown or white eyed flies?")
print("Please choose [b] for brown eyes and [w] for white eyes!")
q2=input("Your choice: ")
while (True):
#flies - brown eyes
if q2=="b":
print("brown eyes it is!")
#flies - brown eyes - gender
print("Which fly for the cross should have red eyes?")
print("Please choose [f] for female or [m] male.")
browneyes=input("The fly with red eyes is: ")
while(True):
#flies - brown eyes - red female
if browneyes=="f":
print("A red eyed female fly crossed with a male brown eyed fly results in:")
print("generation F1: 100% red eyed flies!")
print("generation F2: 75% red eyed flies and 25% brown eyed flies.")
break
#flies - brown eyes - red male
if browneyes=="m":
print("A red eyed male fly crossed with a female brown eyed fly results in:")
print("generation F1: 100% red eyed flies!")
print("generation F2: 75% red eyed flies and 25% brown eyed flies.")
break
else:
print("ERROR please try again")
print("Which fly for the cross should have red eyes?")
print("Please choose [f] for female or [m] male.")
browneyes=input("Your choice: ")
#flies - white eyes
if q2=="w":
print("white eyes it is!")
#flies - white eyes - gender
print("Please choose [f] for female or [m] male.")
whiteeyes=input("The fly with red eyes is: ")
while(True):
#flies - white eyes - red female
if whiteeyes=="f":
print("A red eyed female fly crossed with a male white eyed fly results in:")
print("generation F1: 100% red eyed flies!")
break
#flies - white eyes - red male
if whiteeyes=="m":
print("A red eyed male fly crossed with a female white eyed fly results in:")
print("generation F1: 50% red eyed and white eyed flies each.")
break
else:
print("ERROR please try again")
print("Please choose [f] for female or [m] male.")
whiteeyes=input("Your choice: ")
#choose brown/white - wrong input
else:
print("ERROR please try again")
print("Please choose [b] for brown eyes and [w] for white eyes!")
q2=input("Your choice: ")
#choose human/fly - wrong input
else:
print(" ")
print("ERROR please try again")
print("Please choose [h] for humans and [f] for fruit flies for further options!")
q1=input("Your choice: ")
input(">>>Press Enter to start again!<<<")