mikeizbicki / cmc-csci040

Computing for the Web
37 stars 58 forks source link

Reddit Bot Question #291

Closed jacksonaldrich closed 1 year ago

jacksonaldrich commented 1 year ago

Hello Mike,

I keep getting this error:

File "/Users/jacksonaldrich/topic_00_HTML/bot.py", line 195, in random_comment = random.choice(comments_without_replies) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/random.py", line 378, in choice return seq[self._randbelow(len(seq))]

Do you know what it means / what I can do to fix it? I changed no code and it appeared all of a sudden after working. Thanks!

mikeizbicki commented 1 year ago

Without the full error message, there's not much I can do to help you out here. (You didn't even include the name of the exception you're getting.)

There's a good chance, however, that you're calling random.choice on an empty list.

jacksonaldrich commented 1 year ago

Oh right, sorry. Here is the error:

IndexError: list index out of range

Thanks!

jacksonaldrich commented 1 year ago

I put a try and except statement around these lines and it seemed to fix the error - I'll keep digging to see what the root cause is, though