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):
|
def create_tree(lines, index, counts):
|
||||||
text = lines[index[0]]
|
text = lines[index[0]]
|
||||||
index[0] += 1
|
index[0] += 1
|
||||||
|
|
||||||
node = Node(text)
|
node = Node(text)
|
||||||
|
|
||||||
if text.endswith("?"):
|
if text.endswith("?"):
|
||||||
@ -20,12 +21,11 @@ def create_tree(lines, index, counts):
|
|||||||
return node
|
return node
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
print("Expert zo zoo to vie.")
|
||||||
|
print()
|
||||||
lines = []
|
lines = []
|
||||||
|
|
||||||
print("Expert zo zoo to vie.")
|
|
||||||
while True:
|
while True:
|
||||||
line = input()
|
line = input()
|
||||||
if line == "":
|
if line == "":
|
||||||
@ -38,13 +38,22 @@ def main():
|
|||||||
|
|
||||||
counts = [0, 0]
|
counts = [0, 0]
|
||||||
index = [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 otazok: {counts[0]}")
|
||||||
print(f"Pocet odpovedi: {counts[1]}")
|
print(f"Pocet odpovedi: {counts[1]}")
|
||||||
print("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.")
|
print("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
current = root
|
current = root
|
||||||
|
|
||||||
while current.text.endswith("?"):
|
while current.text.endswith("?"):
|
||||||
@ -54,6 +63,7 @@ def main():
|
|||||||
except EOFError:
|
except EOFError:
|
||||||
print("Koniec vstupu")
|
print("Koniec vstupu")
|
||||||
return
|
return
|
||||||
|
|
||||||
if answer == "a":
|
if answer == "a":
|
||||||
current = current.yes
|
current = current.yes
|
||||||
elif answer == "n":
|
elif answer == "n":
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user