Random module doesn't work as in the exercise


I’m currently reading “Python for Everybody - Exploring Data Using Python 3” by Charles R. Severance.

In the book I’m currently learning about the random module and after replicating the code in pycharm I get a different result than the one in the book and I can’t seem to understand why that is. Could someone help me out please?

Thank you!

Here’s the link so that you can see what’s in the book and what my result is: https://imgur.com/a/V6hYJFM


different code


I’m sorry, but I don’t know what you mean by ‘different code’


It’s different


to me it looks exactly the same as in the book, can you tell me what is different?


It’s very short, I trust you can compare. Worst case you have to compare each character one at a time. There still aren’t many.

You can also look at the output and consider where it could at all be getting that information from.


Only after I copied it I realized the x :man_facepalming: thanks!


Note that you just made a great argument for not using single-letter variable names.

If the bug is telling an outright lie you may be able to tell without looking at any of the rest just because of the names.

# eh. doesn't seem right.

# eh. I don't see anything wrong here.

i is rather common to mean something like index or iteration though.
and in extremely small (probably less than 5-10 lines to make up numbers) amounts of code I wouldn’t complain, one is supposed to be able to eyeball that, or reason it out


That’s true, I’m trying to put a meaning to the names of my variables, this time was trying to quickly test what was in the book, obviously making a mistake.