I want users to enter random words/numbers/phrases. If they have entered more then 5 then they get an error message and if the enter 5 or less then I print out the list vertically. I don't know what code to use so that it does not count the white spaces. As well, I want to count the number of words/numbers, NOT the amount of characters. If you could just take a look at my code and give some help, that would be great!
myList = []
myList = raw_input("Enter words,numbers or a phrase (a phrase should be entered between two quotations)...")
if len(myList) > 5:
print('Error')
else:
#print output
for variable in L:
print variable
Try something like this using str.split() to return a list of the words in the string using the default delimiter of a space character:
Try it here!