So this new problem I have come to is this. I have a two lists with five items each.
listone = ['water', 'wind', 'earth', 'fire', 'ice']
listtwo = ['one', 'two', 'three', 'four', 'five']
What I want to do is print the first, second, third and fifth items from each of these lists in a string:
print("the number is %s the element is %s" % (listtwo, listone)
But they need to print in a new row each time so that the text is run for each of the elements in the two lists:
the number is one the element is water
the number is two the element is wind
the number is three the element is earth
the number is five the element is five
I have no idea how to do this. I tried using list split but since its the fourth item out of five I can’t figure out how to skip it. Also I use this to list the string in a new row:
for x in listone and listtwo:
print("the number is {0} the element is {0}".format(x)
But I don’t know how to use this with two lists or if it even can be used with two lists.
Please help 🙁
EDIT:
Also I don’t know what the elements of the scripts are so I can only use their number in the list. So I need to get rid of [4] in both lists.
Explanation
zip(listone,listtwo)gives you a list of tuples(listone[0],listtwo[0]), (listone[1],listtwo[1])...the
enumerate(listone)gives you a list of tuples(0, listone[0]), (1, listone[1]), ...](you guessed it, it’s another, more efficient way to do
zip(range(len(listone)),listone)0and that you don’t want the fourth element, just check that the index is not3