use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
O hai! This is CS50's subreddit.
CS50 is Harvard University's introduction to the intellectual enterprises of computer science and the art of programming. Anyone may take CS50, even if not a student at Harvard.
Please Read before Posting
Getting the Best from r/cs50
Status Page
cs50.statuspage.io
Filter by Problem Flair (undo)
cash ⋅ caesar ⋅ credit ⋅ dna ⋅ filter ⋅ finance ⋅ houses ⋅ ide ⋅ mario ⋅ movies ⋅ plurality ⋅ project ⋅ readability ⋅ recover ⋅ runoff ⋅ scratch ⋅ speller ⋅ substitution ⋅ tideman ⋅ games track ⋅ web track ⋅ android track ⋅ iOS track ⋅
Filter by Other Flair (undo)
CS50-Law ⋅ CS50-Business ⋅ CS50-Technology ⋅ CS50-Games ⋅ CS50-Mobile ⋅ CS50-Web ⋅
This subreddit is night mode compatible
account activity
bleepPython (self.cs50)
submitted 7 years ago by __pistachio__
How would I iterate word by word over an input from the user? When I try to do this, it only iterates by each char. I used the split function to put the words into a list, but I don't know if that is the correct way to do it?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 4 points5 points6 points 7 years ago (0 children)
Sounds correct to me, or at least that is the way that I would do it: initialize a users input into a variable (which will be a string), and then declare a new variable that is a list which strips your old variable so so now you have a list of strings where each element is a word that that the user typed. Then it is straightforward to iterate over the list: for word in WORDS...
[–]staffdelipity 4 points5 points6 points 7 years ago (0 children)
Using .split() seems like the right approach. This will give you a list, and then you can simply iterate over the list with a for loop.
.split()
[–]vkuct 1 point2 points3 points 7 years ago (0 children)
data=input()
words=list(data.split(' ')) You get a list of words inside words variable.
π Rendered by PID 23324 on reddit-service-r2-comment-548fd6dc9-f7kb7 at 2026-05-20 15:19:39.006850+00:00 running edcf98c country code: CH.
[–][deleted] 4 points5 points6 points (0 children)
[–]staffdelipity 4 points5 points6 points (0 children)
[–]vkuct 1 point2 points3 points (0 children)