Python Forum

Full Version: how to correctly index
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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:])
names = ["Mike", "Johnson","Kennedy"]
print(names[0])
print(names[1])
Output:
Mike Johnson