Lesson 10: Lists

posted Jan 18, 2019, 8:03 AM by Attila Lengyel
names = ["Kayden"]

names.append("Soham")
names.append("Jerry")
names.append("Kian")
names.append("Mahin")
names.append("Anshay")
names.append("Karthik")
names.append("William")
names.append("Sumedh")
names.append("Yahia")

print(names)

for name in names:
print("Hello", name, "!!!")

print("There are", len(names) - 1, "students in the class!")

print(names[0])
names.insert(2, "Attila")

print(names)

if "Mahin" in names:
print(names.index("Mahin"))
print(names[names.index("Mahin")])

names.sort()
print(names)

names.sort(reverse=True)
print(names)

import random, time

print(.9**20)

length = len(names)
for i in range(length):
select = random.randint(0, len(names)-1)
print(names[select], "stand up!!!")
names.remove(names[select])
time.sleep(3)

Comments