Shout the Names
Python
15 pts
Shout the Names
Use list comprehensions to create two new lists from names:
upper_names— every name in capital letters (use.upper()).long_names— only the names with more than 4 letters (uselen()in a condition).
Print both lists. Expected output:
['SELAM', 'ABEL', 'HANA', 'MERHAWI'] ['selam', 'merhawi']
Checklist
- Keep the list
namesunchanged. - Create
upper_nameswith a list comprehension that uses.upper(). - Create
long_nameswith a comprehension that keeps only names with more than 4 letters. - Print
upper_namesand thenlong_names.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
