Python Forum

Full Version: recall
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
how do you recall a item from a list
Not really sure what your asking for but, here are some examples of getting list elements
mylist = ['one', 'two', 3, 4, 'five', 'six']
print(mylist)

# Print all list values:
for item in mylist:
    print(item)

# print list item by index
#  list index starts at 0
print(f'first item -> {mylist[0]}, item 4 -> {mylist[3]}')

# List and index number
for i, item in enumerate(mylist):
    print(f'index: {i} list item: {item}')
Output:
['one', 'two', 3, 4, 'five', 'six'] one two 3 4 five six first item -> one, item 4 -> 4 index: 0 list item: one index: 1 list item: two index: 2 list item: 3 index: 3 list item: 4 index: 4 list item: five index: 5 list item: six