Created
June 17, 2016 14:16
-
-
Save KHerb/72ba9637c18300fee63d9eb024657ac9 to your computer and use it in GitHub Desktop.
Element Search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
lst = [i for i in range(random.randrange(0,1000))] | |
n = int(raw_input("Enter a number to see if it's in the list range: ")) | |
def elementsearch(lst,n): | |
if n in lst: | |
return True | |
else: | |
return False | |
if elementsearch(lst,n) == True: | |
print "%d is in the list range" % n | |
if elementsearch(lst,n) == False: | |
print "%d is NOT in the list range" % n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
user_input = input("Enter a list of numbers from least to greatest over here: ")
user_input_2 = input("Enter the number you want to check to see if it's in the above list over here: ")
if user_input_2 in user_input:
print("This number is in the list you entered.")
if user_input_2 not in user_input:
print("This number is not in the list you entered.")
another solution with user input