Finding The Position Of An Item In Another List From A Number In A Different List
Developing on my previous question I'm wondering whether there is a way to have an element in a list and find that position in another list and return what is in the position as a
Solution 1:
You can do something like this :
input_num = 123
list1 = [0, 1, 2, 3, 4] # if list1 is not dervied from input number
list2 = ["0", "hello", "my", "name", "is", "Daniel"]
print(' '.join([list2[list1.index(int(ind))] for ind instr(input_num)]))
This will result in :
hello my name
Also, i would suggest you to look at the https://docs.python.org/2/tutorial/datastructures.html and trying things out to learn.
Solution 2:
I think that this will solve your problem: for x in list1: print list2[x]
Is it that what you were asking ?
Post a Comment for "Finding The Position Of An Item In Another List From A Number In A Different List"