Python: Logical Operator "Or" (Exclusive Probability)

Post Reply
User avatar
Jason
Site Admin
Posts: 853
Joined: Tue Jul 01, 2025 10:13 am

Note: There is no Python operator showing inclusive probability, that would be where one or the other or both are the correct choice, so in this case, only one or the other, but not both can be correct (Inclusive Probability).

Code: Select all

print("Let's see if you can pick one out of two unknown positive numbers under 6.")

try:

	the_chosen_number = int(input("Pick the number:"))

	if(the_chosen_number == 5 or 1):

		print("You chose one out of the two correct numbers which  were 5 or 1.")
		
except ValueError:

	return "Please pick an integer."

else:

	print("Sorry, you didn't get one of the correct numbers.")



 

POSTREACT(ions) SUMMARY

Post Reply