How can I print player’s names with their scores?
** (Player) Has (Score) Points
Here's My Code 👇🏼
#python 3.7.1
print ("Hello, Dcoder!")
players = ["Akshit","Bhavya", "Hem", "Jayu", "Jay M", "Jay Savla", "Miraj", "Priyank", "PD", "Pratik"]
score = [0,0,0,0,0,0,0,0,0,0]
#0 = Akshit
#1 = Bhavya
#2 = Hem
#3 = Jayu
#4 = Jay M
#5 = Jay Savla
#6 = Miraj
#7 = Priyank
#8 = PD
#9 = Pratik
#10 = Shamu
print (players)
print (score)
players.append("Shamu")
score. append(0)
#RRvCSK
score[9] = (score[9]+100)
score[7] = (score[7]+50)
score[4] = (score[4]+30)
print ("Result")
print (players)
print (score)
players = ["Akshit","Bhavya", "Hem", "Jayu", "Jay M", "Jay Savla", "Miraj", "Priyank", "PD", "Pratik"]
score = [0,1,2,3,4,5,6,7,8,9]
for player, sc in zip(players, score):
print("{} has {} points".format(player, sc))
Output:
Akshit has 0 points
Bhavya has 1 points
Hem has 2 points
Jayu has 3 points
Jay M has 4 points
Jay Savla has 5 points
Miraj has 6 points
Priyank has 7 points
PD has 8 points
Pratik has 9 points
zip
1 makes an iterator by aggregating elements from each of the iterables (here, we have players
and score
lists). Every element from players
and score
are taken together and then printed to the console on the next line.