The program chooses a random integer and based on what number it picks, a certain message will display. I need help in building an if/else statment where all messages have the same chance of being randomly picked and cannot print more than one message at a time. must use if/else statments i included a screenshot of what the program should accomplish
The
I need help in building an if/else statment where all messages have the same chance of being randomly picked and cannot print more than one message at a time.
must use if/else statments
i included a screenshot of what the program should accomplish
The program given chooses a random integer and based on the random number choses a respective message is printed in Output. The error in the code given by you is the use of if-else statements. In the required program only simple if-else statements are needed, if we will use nested if-else statements then multiple sentences can be printed and output will be wrong.
Use if-else statements in sequence to check which number is generated, else-if is written as elif in python so I have used this keyword in the code.
Correct Code is Given below.
Step by step
Solved in 4 steps with 4 images