Why is 1 or 0 when i put x%=2 and my variable x i set 2 or another pair number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why is 1 or 0 when i put x%=2 and my variable x i set 2 or another pair number

For example x=8 x=x%2 if i run this the result is 1, why?? But y=x%2 this is 0 I don't understand

3rd May 2020, 6:21 AM
Deysi Lucero Puscan Remon
Deysi Lucero Puscan Remon - avatar
3 Answers
+ 5
x = 8 x = x % 2 print(x) The above prints 0. If you are still getting 1 as a result, there should be other factors in play and we will need to view more of your code to understand what is going on.
3rd May 2020, 6:28 AM
Hatsy Rei
Hatsy Rei - avatar
3rd May 2020, 6:26 AM
Kevin ★
+ 2
Thanks a lot, i realized my error, plop i had put before x+=3 and i forgot python is dynamic en serio gracias!! :D
3rd May 2020, 6:38 AM
Deysi Lucero Puscan Remon
Deysi Lucero Puscan Remon - avatar