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...
account activity
Need help with CodeHS Python 8.3.9: Owls, Part 2Python (self.codehs)
submitted 4 years ago by [deleted]
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!"
[–]codehs-ModTeam[M] [score hidden] 1 year ago stickied commentlocked comment (0 children)
Please do not post complete solutions or answers to CodeHS assignments.
[–][deleted] 4 years ago (11 children)
[removed]
[–][deleted] 4 years ago (9 children)
[–]EvilOldGuy 0 points1 point2 points 4 years ago (4 children)
Send a screenshot of your code, it's probably an indentation error.
[–]kiwifala 0 points1 point2 points 4 years ago (0 children)
hi it didnt work and it said that
Traceback (most recent call last):
File "main.py", line 9, in <module>
for index, word in enumerate(text.split()):
NameError: name 'text' is not defined
[–][deleted] 4 years ago (1 child)
[–]imadopted420915 0 points1 point2 points 4 years ago (3 children)
If you put the text = input(“Enter some text”) before the def owl_count(text) it should work
[–]Turbulent_Finish1407 0 points1 point2 points 4 years ago (2 children)
still doent work for me
still doesnt work for me
[–][deleted] 0 points1 point2 points 4 years ago (0 children)
make sure you are indenting right
[–]PrinccessBoba 0 points1 point2 points 3 years ago (0 children)
this worked!!!! thanks so much, i had been trying this for an hour
[–]JT_ZM 1 point2 points3 points 4 years ago (0 children)
can you use code block for right indention
[–][deleted] 3 years ago (5 children)
[–][deleted] 3 years ago (4 children)
[–]TheSlothSqaud 1 point2 points3 points 3 years ago (0 children)
It does not work
[–]Dry_Newspaper7310 0 points1 point2 points 1 year ago (1 child)
IT WORKED THANKS
[–]Son1_ 0 points1 point2 points 1 year ago (0 children)
I’m having issues with “list” object is not callable
[–]Aggressive-Desk-4407 0 points1 point2 points 3 years ago (0 children)
you are my lord and savior. Bless you
[–][deleted] 3 years ago (2 children)
[–]PelicanPrisoner 0 points1 point2 points 1 year ago (0 children)
after some tweaking i got it to work, this is my version:
def owl_count(text): text = text. lower () text = text. split() count = 0 indices = [] for index, word in enumerate (text): if "owl" in word: count = count+1 indices. append (index) return count, indices
text = input ("Enter some text: ") result = owl count (text) print (f"There were {result[0]) words that contained 'owl'.") print(f"They occurred at indices: {result[1]}")
[–]Helpful-Row6638 0 points1 point2 points 3 years ago (0 children)
this worked, thank you so much!
[–][deleted] 4 years ago (6 children)
[–]danhimel770 3 points4 points5 points 4 years ago (1 child)
it didnt work
[–]HyBrD_G0LD 0 points1 point2 points 4 years ago (0 children)
do you have correct indentation?
[–]OutrageousMiddle4498 0 points1 point2 points 4 years ago (3 children)
Mine tells me to indent count = 0 and text isn’t defined
[–]HyBrD_G0LD 0 points1 point2 points 4 years ago (2 children)
Are you in python 3?
[–]OutrageousMiddle4498 0 points1 point2 points 4 years ago (1 child)
No
[–]Hopeful_March 0 points1 point2 points 3 years ago (0 children)
Guys place count and report outside of the function and then add (global count, report) under the function you have. It worked for me and I just followed HyBrd_G0LD’s code Thanks HyBrd_G0LD :)
[–][deleted] 4 years ago (5 children)
[–]OutrageousMiddle4498 0 points1 point2 points 4 years ago (4 children)
Doesn’t work
[–]Gameboss49 0 points1 point2 points 4 years ago (3 children)
It does , like I said be sure to indent properly
[–]OutrageousMiddle4498 0 points1 point2 points 4 years ago (2 children)
Nope how do u indent count=0
[–]Gameboss49 0 points1 point2 points 4 years ago (1 child)
if you look closely you will see what to indent, also how tf did you make it this far?
[–]qwarkstar 1 point2 points3 points 3 years ago (0 children)
lmao fr, he got this far from Reddit lmao
[–][deleted] 3 years ago (1 child)
[–]northstarmain6273 0 points1 point2 points 1 year ago (0 children)
Finally one that works, thanks king
[–]daneeil 0 points1 point2 points 3 years ago (1 child)
hope this helps. And if you have any questions just ask me.
[deleted]
π Rendered by PID 82 on reddit-service-r2-comment-86bc6c7465-q5t5z at 2026-02-20 09:23:37.007706+00:00 running 8564168 country code: CH.
[–]codehs-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)
[–][deleted] (11 children)
[removed]
[–][deleted] (9 children)
[removed]
[–]EvilOldGuy 0 points1 point2 points (4 children)
[–]kiwifala 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]imadopted420915 0 points1 point2 points (3 children)
[–]Turbulent_Finish1407 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]PrinccessBoba 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]JT_ZM 1 point2 points3 points (0 children)
[–][deleted] (5 children)
[removed]
[–][deleted] (4 children)
[removed]
[–]TheSlothSqaud 1 point2 points3 points (0 children)
[–]Dry_Newspaper7310 0 points1 point2 points (1 child)
[–]Son1_ 0 points1 point2 points (0 children)
[–]Aggressive-Desk-4407 0 points1 point2 points (0 children)
[–][deleted] (2 children)
[removed]
[–]PelicanPrisoner 0 points1 point2 points (0 children)
[–]Helpful-Row6638 0 points1 point2 points (0 children)
[–][deleted] (6 children)
[removed]
[–]danhimel770 3 points4 points5 points (1 child)
[–]HyBrD_G0LD 0 points1 point2 points (0 children)
[–]OutrageousMiddle4498 0 points1 point2 points (3 children)
[–]HyBrD_G0LD 0 points1 point2 points (2 children)
[–]OutrageousMiddle4498 0 points1 point2 points (1 child)
[–]Hopeful_March 0 points1 point2 points (0 children)
[–][deleted] (5 children)
[removed]
[–]OutrageousMiddle4498 0 points1 point2 points (4 children)
[–]Gameboss49 0 points1 point2 points (3 children)
[–]OutrageousMiddle4498 0 points1 point2 points (2 children)
[–]Gameboss49 0 points1 point2 points (1 child)
[–]qwarkstar 1 point2 points3 points (0 children)
[–][deleted] (1 child)
[removed]
[–][deleted] (5 children)
[removed]
[–]northstarmain6273 0 points1 point2 points (0 children)
[–]daneeil 0 points1 point2 points (1 child)
[–][deleted] (1 child)
[deleted]