Recap - Elements Of Freedom
Part of the Logic & Flow section of Coddy's Python journey — lesson 55 of 78.
Challenge
EasyCreate a function named elements_of_freedom that processes a list of string elements according to specific rules.
Your function should:
- Filter out elements that have fewer than 5 characters
- Convert the remaining elements to uppercase
- Remove any duplicate elements
- Return a list of the unique uppercase elements
Use list operations to efficiently process the data.
Note: Preserve the original order of elements in the list.
Example:
Input: ["apple", "banana", "cherry", "date", "apple", "banana", "grape", "fig"]
Output: ['APPLE', 'BANANA', 'CHERRY', 'GRAPE']Try it yourself
def elements_of_freedom(elements):
# Your solution here
# Step 1: Filter elements with length >= 5
# Step 2: Convert filtered elements to uppercase
# Step 3: Create a list of unique elements
# Step 4: Return the final result
passAll lessons in Logic & Flow
1Variables Exploration
ConstantsMultiple Variable AssignmentsSwapping VariablesPlaceholder VariablesRound NumbersList Casting4Contact Book Application
Display MenuAdd Contact7Sets Part 2
Mathematical Operations Part 1Mathematical Operations Part 2Recap - Treasure HuntSubsets and SupersetsIterating Over SetsRecap - Tournament Tracker10Basic List Comprehensions
The SyntaxCreating Simple ListsAdding ConditionsUsing Data AggregationRecap - House Of ListsRecap - Elements Of Freedom2Dictionaries Part 1
What is a Dictionary?Creating a DictionaryAccessing ValuesModifying DictionariesRecap - Recipe Manager5Advanced Decision Making
Ternary OperatorMembership ChecksIdentity ChecksIndentation ErrorsRecap - Vacation Filter8Student Records Manager
Project OverviewAdd Student11Advanced Functions
Returning Multiple ValuesLambda Functions Part 1Lambda Functions Part 2Recap Challenge - Lambda SortRecursive Functions Part 1Recursive Functions Part 2Recap - Sum Nested List14Higher-Order Functions
The Map FunctionThe Filter FunctionRecap - Email ValidatorRecap - Number Processor3Dictionaries Part 2
Dictionary MethodsNested DictionariesChecking for KeysLooping Through DictionariesRecap - Frequency Counter9Advanced Data Aggregation
Using SumFinding Minimum and MaximumSorting Data EfficientlyRecap - Dictionary Sorter