feat: Initial commit
This commit is contained in:
30
Laboratorio10/vendite.py
Normal file
30
Laboratorio10/vendite.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from sys import exit
|
||||
|
||||
def main():
|
||||
try:
|
||||
fio = open("vendite.txt", "r")
|
||||
except FileNotFoundError:
|
||||
exit("File not found")
|
||||
|
||||
datas = {}
|
||||
|
||||
for line in fio:
|
||||
data = line.split(";")
|
||||
if len(data) != 4:
|
||||
exit("Invalid line: " + line)
|
||||
|
||||
service = data[1].strip()
|
||||
cost = float(data[2].strip())
|
||||
|
||||
if service not in datas:
|
||||
datas[service] = 0
|
||||
|
||||
datas[service] += cost
|
||||
|
||||
|
||||
for key in datas:
|
||||
print(key + ":", datas[key])
|
||||
|
||||
fio.close()
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user