28 lines
681 B
Python
28 lines
681 B
Python
file = open("survey.txt", "r")
|
|
list1 = ["Bel", "Eng", "Ger", "Fra", "Ita", "Spa","Cam"]# hiermee open je het bestand enkel om het te lezen
|
|
my_set = set()
|
|
count = 0
|
|
for line in file.readlines(): # hiermee lees je het bestand lijn per lijn
|
|
line = line.strip()
|
|
line_split = line.split()
|
|
for i in line_split:
|
|
my_set.add(i)
|
|
|
|
for team in line_split:
|
|
if team == "Bel" or "Ger":
|
|
count += 1
|
|
|
|
print("aantal fans: ",count)
|
|
|
|
for woord in list1:
|
|
if woord not in my_set:
|
|
print(woord+" is niet gekozen.")
|
|
|
|
|
|
|
|
# hier kan je de lijn gebruiken in een functie
|
|
file.close() # sluit de file
|
|
|
|
|
|
|