Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Array=['john','jack','jill']
- # Flag to check if search found the value. Set to False by default
- checked = False
- #function to check through the array
- def array_check(Userinput):
- position=0
- global checked
- #global is needed to use a variable outside of the function
- while position<len(Array):
- if Userinput == Array[position]:
- print('Found it')
- checked = True
- position=position+1
- # This is the second While loop. Using a function makes this much more elegant
- while checked == False :
- Userinput = input('Type the item for search:')
- array_check(Userinput)
- print(checked)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement