lundi 17 mai 2021

How to check that user has entered the value which is listed in python list eg [1,2,3,4,5]

Eg.

Mylist = [1,2,3,4,5]

User_ip = 3

#user enters a value that is in the python list and if not print- not in the list

I am trying it with for loop but logic not works

for i in Mylist:
    if i== User_ip:
        print ("value is in the list")
    else:
        print ("value not in the list")

Aucun commentaire:

Enregistrer un commentaire