Aug-14-2019, 08:55 AM
You don't have to use a for loop. Here an example, which works also with
tuple
.items = ["Thing", "apple", "dog", "house", "Thing", "bugs", "ducks", "rabbits"] element = "dog" try: index = items.index(element) except VaslueError: index = -1 print(element, 'not found') print('Index is', index) else: print(element, 'found') print(element, 'is at index', index)
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!