You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

30 lines
970 B

#!/usr/bin/env python3
#title :8-4.py
#description :Opdracht 8.4 - File & dict
#author :Marcel Haazen
#email :marcel@haazen.xyz
#date :28-10-2019 - 13:20
#version :0.1
#usage :python3 8-4.py
#notes :
#python_version :3.7.3
#==============================================================================
def ticker():
filename = 'tickers.txt'
tickers = {}
with open(filename) as fh:
for line in fh:
company, ticker = line.strip().split(':', 1)
tickers[company] = ticker.strip()
return tickers
try:
comp = str(input("Enter Company name: ")).upper()
print((ticker())[comp])
except KeyError as identifier:
print("Dit bedrijf in onbekend.")
try:
tick = comp = str(input("Enter Ticker symbol: ")).upper()
print([key for key in ticker().items() if key[1] == tick][0][0])
except StopIteration as identifier:
print("Dit bedrijf in onbekend.")