contints = ["Europe", "North_America", "South_America", "Asia", "Australia", "Africa"]
Europe = "rich life"
North_America = "average life"
South_America = "poor life"
Asia = "average life"
Australia = "rich life"
Africa = "very poor life"
print(random.choice(contints))
if random.choice(contints) == "Europe":
print("You will have a " + Europe)
elif random.choice(contints) == "North_America":
print("You will have a " + North_America)
elif random.choice(contints) == "South_America":
print("You will have a " + South_America)
elif random.choice(contints) == "Asia":
print("You will have a " + Asia)
elif random.choice(contints) == "Australia":
print("You will have a " + Australia)
else:
print("You will have a " + Africa)
This works but when I make a function out of it and change to return statements nothings happens while I want to return the answer. I want that the continent is randomly chosen and then return the output.
import random def continent(contints): contints = ["Europe", "North_America", "South_America", "Asia", "Australia", "Africa"] Europe = "rich life" North_America = "average life" South_America = "poor life" Asia = "average life" Australia = "rich life" Africa = "very poor life" if random.choice(contints) == "Europe": return Europe elif random.choice(contints) == "North_America": return North_America elif random.choice(contints) == "South_America": return South_America elif random.choice(contints) == "Asia": return Asia elif random.choice(contints) == "Australia": return Australia else: return Africa
Aucun commentaire:
Enregistrer un commentaire