total_ask_comments = 0
for post in ask_posts:
total_ask_comments += int(post)
avg_ask_comments = total_ask_comments / len(ask_posts)
What I expected to happen:
It worked perfectly fine and produced the result as avg_ask_comments = 14.03 in the morning, but i had to close the system and then when i started again it showed as value error.
What actually happened:
ValueErrorTraceback (most recent call last)
<ipython-input-24-7c08fe5a41af> in <module>()
4 for post in ask_posts:
----> 5 total_ask_comments += int(post)
7 avg_ask_comments = total_ask_comments / len(ask_posts)
ValueError: invalid literal for int() with base 10: 'H'
Did you try restarting all the kernels after starting to work on your project again? If not, you can go to “Kernel” from the toolbar right above the notebook and click “Restart & Run All”.
Yes I did, but same result.
I’d recommend comparing your previous steps with the solution notebook, then. You might have accidentally deleted a line or something, that sometimes happens to me.
as @dilarakrby mentioned, if you are having an error after restarting, it is highly probable that you either modified the code but ran a cell using a variable that contains an old state or something similar.
Maybe you ran the code with
post being a string instead of a list of strings?