Code works not as intendet | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Code works not as intendet

I wanted to write a code that choose a random number between 100-200 but it also choose numbers under 100. https://code.sololearn.com/c3jVCMcmfJ2T/?ref=app

1st Feb 2019, 9:27 AM
0Trant0
0Trant0 - avatar
5 Answers
+ 7
Got the problem. You used the variable x again in the for loop (line 4): for x in range (1): Therefore the random number range will be from 0 to 200. You need to just change x into z or some other variable (not y either).
1st Feb 2019, 9:36 AM
Seniru
Seniru - avatar
+ 3
I don't think you need to initialize x and y. Just type the values directly inside the parentheses.
1st Feb 2019, 9:37 AM
Pimeys
Pimeys - avatar
+ 3
Lol, I just use all the variable inside the method to make it more complex. That's the pro's way XD
1st Feb 2019, 9:50 AM
Seniru
Seniru - avatar
+ 2
Thank you guys. Yeah, at first i just typed it directly inside but i wanted to make it a bit more "complex".
1st Feb 2019, 9:44 AM
0Trant0
0Trant0 - avatar
+ 2
No need to make the code complex when you can keep it simple ;)
1st Feb 2019, 9:46 AM
Pimeys
Pimeys - avatar