Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
recall
#1
how do you recall a item from a list
Reply
#2
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
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  trying to recall a regex for re.split() Skaperen 23 4,433 May-20-2022, 11:38 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020