How to get confirmation if the input is in a list? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

How to get confirmation if the input is in a list?

i try to make a list from 0-50, and I try to add the input, and if the input number is in the list, want it to print something, else to print something different. Can anybody offer some code samples?

29th Jul 2018, 9:25 PM
Mirza Kadric
Mirza Kadric - avatar
1 Resposta
+ 2
List=list(range(0,51)) inp = int(input("Enter a number")) if inp in List: print("Already in List ") else: print("Not in List")
29th Jul 2018, 10:09 PM
Dlite
Dlite - avatar