fruits = [["Strawberry", 9.00],
["Apple", 7.0],
["Orange", 2.0],
["Guava", 1.75],
["Mango", 15.00]]
Loop out Key and Value
for x,y in enumerate(fruits):
print("the "+ y[0]+" is "+str(y[1]))
the Strawberry is 9.0 the Apple is 7.0 the Orange is 2.0 the Guava is 1.75 the Mango is 15.0
First Alternative to Loop out Key and Value
for x, y in fruits:
print("the " + str(x) + " is " + str(y) )
the Strawberry is 9.0 the Apple is 7.0 the Orange is 2.0 the Guava is 1.75 the Mango is 15.0
Second Alternative to Loop out Key and Value
a="the "
n = 0
for x in fruits:
for y in x:
if n==0 :
a += str(y)
a +=" is "
if n==1 :
a += str(y)
n +=1
print(a)
a ="the "
n =0
the Strawberry is 9.0 the Apple is 7.0 the Orange is 2.0 the Guava is 1.75 the Mango is 15.0