Skip to content

🐍 Program 139: Create Dictionary of Lowercase and Uppercase Letters #162

@iamAntimPal

Description

@iamAntimPal

🐍 Program 139: Create Dictionary of Lowercase and Uppercase Letters

📌 Description

Write a function that creates a dictionary with each (key, value) pair being the (lowercase, uppercase) versions of a letter, respectively.


💡 Code Example

def mapping(lst):
    return {letter: letter.upper() for letter in lst}

# Examples
print(mapping(["p", "s"]))  # ➞ { "p": "P", "s": "S" }
print(mapping(["a", "b", "c"]))  # ➞ { "a": "A", "b": "B", "c": "C" }
print(mapping(["a", "v", "y", "z"]))  # ➞ { "a": "A", "v": "V", "y": "Y", "z": "Z" }

✅ Output

{'p': 'P', 's': 'S'}
{'a': 'A', 'b': 'B', 'c': 'C'}
{'a': 'A', 'v': 'V', 'y': 'Y', 'z': 'Z'}

🧠 Explanation

  • The function uses a dictionary comprehension to iterate over each letter in the input list.
  • For each letter, it maps the lowercase letter (key) to its uppercase version (value).

Metadata

Metadata

Assignees

Labels

PythonPython Interview QuestionsenhancementNew feature or requestquestionFurther information is requested

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions