You are given a messy list of names. Clean each one up — remove surrounding spaces and make it title case (first letter uppercase, rest lowercase) — then print the cleaned list.
Hint: use .strip() to remove spaces and .title() to fix capitalisation. Build a new list with a for loop and .append().
Given the list of names below, find and print the longest name and how many characters it has.
Hint: loop over the list, compare len() of each name to a running maximum, and keep track of which name is longest.
Count how many names in the list below start with the letter A, and print the result.
Hint: use a counter variable, a for loop, and .startswith() inside an if statement.
The list below contains numbers stored as text strings. Convert each one to an integer, then print their total and their average rounded to one decimal place.
Hint: use int() to convert each string inside a for loop, append the results to a new list, then use sum() and len() to calculate total and average.
Using the Greek Prime Ministers dictionary from Chapter Two (Exercise 7), loop through it and print only the Prime Ministers whose name starts with the letter K, along with the year they took office.
Hint: combine .items() to loop the dictionary, .startswith("K") to filter, and an f-string to format the output.
Chapter Navigation
Move between chapters.