I made a program:
import collections
x = input("Enter in text: ")
x_counter = collections.Counter()
x_counter.update(x)
print("Your sequence contains:\n")
for i in '`1234567890-=qwertyuiop[]\asdfghjkl;zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP\
{}|ASDFGHJKL:"ZXCVBNM<>?':
print(i, x_counter[i])
That prints out the number of times a letter has been used in a text.
When the user enters in a smaller sized text, like a paragraph for example…the program runs fine. When the user enters a very long text, say 5 paragraphs…the program quits and runs all of the input as bash commands…Why is this???
That’s because
inputonly gets a single line from the user, as per the following example:One possibility is to read the information from a file rather than using
input, but you can also do something like:which will continue to read input from the user until they end the input with EOF (CTRL-D under Linux):