day 26 - comprehensions
This commit is contained in:
15
026/main.py
Normal file
15
026/main.py
Normal 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])
|
||||
27
026/nato_phonetic_alphabet.csv
Normal file
27
026/nato_phonetic_alphabet.csv
Normal file
@ -0,0 +1,27 @@
|
||||
letter,code
|
||||
A,Alfa
|
||||
B,Bravo
|
||||
C,Charlie
|
||||
D,Delta
|
||||
E,Echo
|
||||
F,Foxtrot
|
||||
G,Golf
|
||||
H,Hotel
|
||||
I,India
|
||||
J,Juliet
|
||||
K,Kilo
|
||||
L,Lima
|
||||
M,Mike
|
||||
N,November
|
||||
O,Oscar
|
||||
P,Papa
|
||||
Q,Quebec
|
||||
R,Romeo
|
||||
S,Sierra
|
||||
T,Tango
|
||||
U,Uniform
|
||||
V,Victor
|
||||
W,Whiskey
|
||||
X,X-ray
|
||||
Y,Yankee
|
||||
Z,Zulu
|
||||
|
5
026/task.py
Normal file
5
026/task.py
Normal file
@ -0,0 +1,5 @@
|
||||
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
|
||||
new_numbers = [ n for n in numbers if n % 2 == 1 ]
|
||||
|
||||
print(new_numbers)
|
||||
Reference in New Issue
Block a user