Jan-18-2017, 02:21 PM
(This post was last modified: Jan-18-2017, 02:21 PM by haiderhussain.)
Hello experts,
Python version : 2.7.10
I am using the below code for assigning the elements : a,b,c,d,e to the list : cities_list.
In order to check my execution, I am using the print statement.
My code :
Thanks,
Haider
Python version : 2.7.10
I am using the below code for assigning the elements : a,b,c,d,e to the list : cities_list.
In order to check my execution, I am using the print statement.
My code :
five_elements = ["a,1","b,2","c,3","d,4","e,5"] cities_list = [] for i in range(0,len(five_elements)): print(five_elements[i][0]) cities_list.append([i][0]) print(cities_list)However, I am getting different outputs :
a b c d e [0, 1, 2, 3, 4]I wish to have the output as :
a b c d eCould you please help me on this.
Thanks,
Haider