Where Is It?¶

Create a list to hold ten random values from 1-50. Display those values on the screen, and then prompt the user for an integer. Search through the list, and if the item is present, give the index position of where it is located. If the value is not in the list, display a single message saying so. If the value is present more than once, you may either display the message as many times as necessary, or display a single message giving the last index position in which it appeared.

Name the file where_is_it.py

List: 45 39 32 12 44 50 42 26 16 20
Value to find: 42

42 is at index 6.
List: 45 39 32 12 44 50 26 42 16 20
Value to find: 43

43 is not in the list.
List: 24 30 31 24 32 33 34 24 35 36
Value to find: 24

    *you may display either*

24 is at index 0.
24 is at index 3.
24 is at index 7.

    *or*

24 is at index 7.

©2021 Daniel Gallo

This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.

Creative Commons License

Adapted for Python from Graham Mitchell’s Programming By Doing