Hi all
I have been using the sys module's stdinput to take input from the user until they enter the keyword 'submit'. Once this happens the dictionary would have stored the key:value pairs for what has been inputted up to this point.
The key:value pairs should print to the user.
The issue I am having is that I can't stop the std input with the keyword 'submit', curious why this is?
Much appreciated
P.S Unfortunately do have to use stdin :)
I have been using the sys module's stdinput to take input from the user until they enter the keyword 'submit'. Once this happens the dictionary would have stored the key:value pairs for what has been inputted up to this point.
The key:value pairs should print to the user.
The issue I am having is that I can't stop the std input with the keyword 'submit', curious why this is?
import sys dictionary_words = {} for line in sys.stdin: for word in line.split(): if word == 'submit': break else: dictionary_words[word] = dictionary_words.get(word,0) + 1 for key,value in dictionary_words.items(): print(key,value)If its of any help, when I compile this py file, I run it in a linux terminal.
Much appreciated
P.S Unfortunately do have to use stdin :)