Lesson 4: Lists

posted Nov 7, 2019, 7:54 AM by Attila Lengyel
silver = ["Zubin", "Nadezda"]
print(silver)
silver.append("Sumukh")
print(silver)
print(silver[1])

silver.append("Enna")
silver.append("Anika")
silver.append("Sarah")
silver.append("Eesha")
silver.append("Tanisha")
silver.append("Claire")
silver.append("Katie")
silver.append("Sumedh")
silver.append("Micah")
silver.append("Alex")
silver.append("Mihir")

print(silver)
print(len(silver))
silver.sort()
print(silver)
silver.reverse()
print(silver)

import random
iplayer1 = random.randint(0, len(silver) - 1)
player1 = silver[iplayer1]
silver.remove(player1)

iplayer2 = random.randint(0, len(silver) - 1)
player2 = silver[iplayer2]
silver.remove(player2)

print(player1, "play against", player2)
print(silver)
Comments