Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def in_list(lst, x):
- if len(lst) == 1:
- return lst[0] == x
- else:
- if lst[-1] == x:
- return True
- else :
- return in_list(lst[:-1], x)
- #Main Program
- lst = ['a','b','c']
- x = 'a'
- print(in_list(lst, x))
- print(in_list(['ant','bird','cat'],'dog'))
Advertisement
Add Comment
Please, Sign In to add comment