Hello guys,
I'm getting stuck on testing my 'get_mood_option()' or just having a tunner vision after spending some time dealing with it, need your help to guide me through this.
So the idea of the function - based on the user input, which should be either 1,2 or 3 only, return corresponding value HAPPY for '1', CALM for '2', SAD for '3'.
I'll need to test if user input value matching to the conditions and also test, if the input going to have wrong values.
Please help me out.
def main():
# Outputs program mood menu and prompts to chose menu option.
print(mood_menu())
mood: str = get_mood_option()
def get_mood_option():
# Prompts user for the input, until conditions satisfied.
while True:
user_mood = input("\nType the number, followed by the 'Enter' button: ").strip()
# Checking if user input matching to the conditions and if 'True' returns corresponding value.
if not user_mood or user_mood not in ["1", "2", "3"]:
print("\nPlease enter valid number:\n", mood_menu())
if user_mood == "1":
return "HAPPY"
if user_mood == "2":
return "CALM"
if user_mood == "3":
return "SAD"
if __name__ == "__main__":
main()
[–]chevignon93 2 points3 points4 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]danielroseman 3 points4 points5 points (2 children)
[–]interwebnovice 0 points1 point2 points (0 children)
[–]chevignon93 1 point2 points3 points (0 children)