I have created code that will do a condition validation statement. I have a menu that prompts the user the enter a number between 1-3 and if the user presses any number besides those 3 numbers, it would tell the user an error message and loop the menu statement again until the condition is met. This is my code
from flask import Flask, request, jsonify, make_response, abort import mysql.connector from mysql.connector import Error import myfunctions import datetime from myfunctions import create_connection, execute_query, execute_read_query, connection from friend_insert import friend_insert from movie_insert import movie_insert from friend_delete import friend_delete from random_movie import random_movie while True: print("Press 1 To Add Friend Information") print("Press 2 To Add Up To 10 Movies Per Friend") print('Press 3 To Select Who Participates And Generate A Random Movie') choice = int(input()) if choice == 1: friend_insert() if choice == 2: movie_insert() if choice == 3: friend_delete() random_movie() break if choice != 1 and 2 and 3: print("Please Try Again")
The loop works. however, it is not showing the error message "Please Try Again." Why is that?
Source: Python Questions