Aktualizovat u8/program.py
This commit is contained in:
parent
1fb6c19c8f
commit
0cbb03de46
@ -8,6 +8,7 @@ class Node:
|
||||
def create_tree(lines, index, counts):
|
||||
text = lines[index[0]]
|
||||
index[0] += 1
|
||||
|
||||
node = Node(text)
|
||||
|
||||
if text.endswith("?"):
|
||||
@ -20,12 +21,11 @@ def create_tree(lines, index, counts):
|
||||
return node
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
print("Expert zo zoo to vie.")
|
||||
print()
|
||||
lines = []
|
||||
|
||||
print("Expert zo zoo to vie.")
|
||||
while True:
|
||||
line = input()
|
||||
if line == "":
|
||||
@ -38,13 +38,22 @@ def main():
|
||||
|
||||
counts = [0, 0]
|
||||
index = [0]
|
||||
root = create_tree(lines, index, counts)
|
||||
|
||||
try:
|
||||
root = create_tree(lines, index, counts)
|
||||
if index[0] != len(lines):
|
||||
print("Chybna databaza")
|
||||
return
|
||||
|
||||
except (IndexError, EOFError):
|
||||
print("Chybna databaza")
|
||||
return
|
||||
|
||||
print(f"Pocet otazok: {counts[0]}")
|
||||
print(f"Pocet odpovedi: {counts[1]}")
|
||||
print("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.")
|
||||
print()
|
||||
|
||||
current = root
|
||||
|
||||
while current.text.endswith("?"):
|
||||
@ -54,6 +63,7 @@ def main():
|
||||
except EOFError:
|
||||
print("Koniec vstupu")
|
||||
return
|
||||
|
||||
if answer == "a":
|
||||
current = current.yes
|
||||
elif answer == "n":
|
||||
|
||||
Loading…
Reference in New Issue
Block a user