I ran into something really strange, a loop without while
This is my function, and the game_lexicon is a dict from a different file, Not sure why it is looping. It will make the tuple list, run all the stuff, and then start over asking for a user input. It runs a second time, overwrites previous info and then shuts down.
I'll update when I figure out what the hell happened. I didn't think a loop was possible without a 'while'
Update:
The error was in my game_lexicon import. I had the same scan function running in that file, so it was running twice. There was no loop.
I'll update when I figure out what the hell happened. I didn't think a loop was possible without a 'while'
Update:
The error was in my game_lexicon import. I had the same scan function running in that file, so it was running twice. There was no loop.
from lexicon import game_lexicon
def scan(some_dict):
tuple_list = []
try:
user_input = input(" give me a sentence...>")
user_words = user_input.split()
print(user_words)
except:
print("input not tested.")
for word in user_words:
key = word
print(key)
success =False
try:
int(word) == word
#print(f"the integer {word} is accepted.")
tuple_list.append(('number', word))
success = True
except ValueError:
for key in some_dict:
val = some_dict.get(key)
if word in val:
#print(f"word {word} FOUND!")
#print(f"{word} was found in {key} list")
tuple_list.append((key, word))
success = True
else:
print(f"word not found in {key}")
# i need a way to create tuples of errors that are not found in the lexicon
finally:
if not success:
tuple_list.append(('error', word))
else:
print("This word added to tuple list.")
print(tuple_list)
#scan(game_lexicon)
Comments
Post a Comment