-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclase6_code_magnets.py
More file actions
28 lines (18 loc) · 875 Bytes
/
clase6_code_magnets.py
File metadata and controls
28 lines (18 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
impuesto = 1.13
with open('lista_compras.txt', 'r') as f:
lista = f.readlines()
quita_fin_de_linea = [elemento.rstrip() for elemento in lista]
# # tradicionalmente
# quita_fin_de_linea = []
# for elemento in lista:
# #puedo agregar mas logica
# quita_fin_de_linea.append(elemento.rstrip())
lista_fruta_precio = [elemento.split(',') for elemento in quita_fin_de_linea]
lista_fruta_precio_impuesto = []
for fruta, precio in lista_fruta_precio:
lista_fruta_precio_impuesto.append([fruta, str(round(int(precio) * impuesto))])
list_reglon = [','.join(elemento) for elemento in lista_fruta_precio_impuesto]
#pone_fin_de_linea = [f'{elemento}\n' for elemento in list_reglon]
pone_fin_de_linea = [elemento for elemento in list_reglon]
with open('lista_compras_procesada.txt', 'w') as f:
f.writelines(pone_fin_de_linea) # ocupa una lista de reglones!!!!