Advertisement
Txemin

Untitled

May 20th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. from random import randint
  2. sequence = [randint(0, 100) for i in range (20)]
  3. print(sequence)
  4.  
  5. number = int(input( "\n Which number between 0 - 100 should I look for? "))
  6. samler = []
  7. found = False
  8. for position in range(len(sequence)):
  9. loop = True
  10. while loop:
  11. if sequence[position] == number:
  12. print(number, "is at position", str(position))
  13. samler.append(position)
  14. found = True
  15. loop = False
  16. else:
  17. loop = False
  18. if found == True:
  19. print("\n Your number(s) is/are in position(s) {}\n ".format(samler))
  20. else:
  21. print( "\n Your number is not in the set \n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement