day 26 - comprehensions

This commit is contained in:
Tanguy Deleplanque
2025-07-17 09:37:07 +02:00
parent 612ad7c549
commit ce3befd167
4 changed files with 50 additions and 4 deletions

15
026/main.py Normal file
View File

@ -0,0 +1,15 @@
import pandas as pd
# Keyword Method with iterrows()
# {new_key:new_value for (index, row) in df.iterrows()}
#TODO 1. Create a dictionary in this format:
# {"A": "Alfa", "B": "Bravo"}
data = pd.read_csv("nato_phonetic_alphabet.csv")
dict = { row.letter:row.code for (index, row) in data.iterrows() }
#TODO 2. Create a list of the phonetic code words from a word that the user inputs.
input = list(input("Which word do you want to spell?\n"))
print([ dict[letter.upper()] for letter in input])