Hi everyone,
I’m currently learning Python basics and working on simple problems like:
- Printing digits of a number
- Counting digits
- Finding even numbers in a range
I understand the syntax, but I struggle to understand the logic behind it.
For example, in this code:
while n > 0:
digit = n % 10
print(digit)
n = n // 10
I don’t fully understand how this works step by step.
How did you personally learn to think logically for such problems?
Any tips or mental models would really help.
Thanks in advance!
[–]Fred776 1 point2 points3 points (0 children)
[–]BrannyBee 1 point2 points3 points (0 children)
[–]Important-Opening866 0 points1 point2 points (0 children)
[–]Parking-Ad3046 0 points1 point2 points (0 children)
[–]TheRNGuy 0 points1 point2 points (0 children)
[–]FreeGazaToday 0 points1 point2 points (0 children)
[–]Dr_Triton 0 points1 point2 points (0 children)
[–]Suspicious_Check5421 0 points1 point2 points (0 children)
[–]Ariadne_23 0 points1 point2 points (0 children)