Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to correctly index
#1
My goal is to print only 1 name out of 3 on the list. however, I end up with the wrong results like

ike
ohnson
ennedy

below is my code in python:

names = ["Mike", "Johnson","Kennedy"]
for name in names:
print(name[1:])
Reply
#2
names = ["Mike", "Johnson","Kennedy"]
print(names[0])
print(names[1])
Output:
Mike Johnson
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Forum Jump:

User Panel Messages

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