mardi 9 janvier 2018

Selecting item from lists with multiple elements Python

I could to come up with a good title and am not all that good at programming but I will try to explain my problem as good as I can below.

Basically I have a list like this

persons = ["Peter", 22, "Jon", 26, "Ann", 27, "Mark", 23, "Susan", 30]

and what I want is for something to happen if the persons name is for example Peter.

so I cant do

if persons[0]=='Peter' do_something

because persons[0] is also the age

how do I just get access to "if the name of person[0] is Peter"

Aucun commentaire:

Enregistrer un commentaire