I want to display an answer based on what value in an array the user input matches. So I want the if statement to see if what was entered matches any values in the array.
Asked
Active
Viewed 2,220 times
2 Answers
0
You can use in statement:
array = [1, 4, 9, 16]
element = int(input())
if element in array:
print("Okay")
Ilya V. Schurov
- 7,038
- 2
- 37
- 74