days_of_week = ["Mon", "Tue", "Wed", "Thur", "Fri"]
print(days_of_week.count("Wed"))
# 1
days_of_week.reverse()
print(days_of_week)
#['Fri', 'Thur', 'Wed', 'Tue', 'Mon']
print(days_of_week[3])
# Tue
player = {
'name' : 'user',
'age' : 20,
'alive' : True,
'fav_food' : ["pizza", "hamburger"]
}
player['fav_food'].append("noodle")
print(player.get('fav_food'))
print(player['fav_food'])
# ['pizza', 'hamburger', 'noodle']
['pizza', 'hamburger', 'noodle']
from requests import get
websites = [
"google.com",
"airbnb.com",
"x.com",
"facebook.com",
"tiktok.com"
]
results ={}
for website in websites:
if not website.startswith("https://"):
website = f"https://{website}"
response = get(website)
if response.status_code >= 200 and response.status_code < 300:
results[website] = "OK"
elif response.status_code >= 300 and response.status_code < 400:
results[website] = "REDIRECT"
elif response.status_code >= 400 and response.status_code < 500:
results[website] = "ERROR"
else:
results[website] = "FAILED"
print(results)
# {'https://google.com': 'OK', 'https://airbnb.com': 'OK', 'https://x.com': 'OK', 'https://facebook.com': 'OK', 'https://tiktok.com': 'OK'}