I wrote code to print all prime numbers but i cant even understand it even tho i wrote it myself pls help!!!

```
num = 1
while True:
for i in range(1,num):
print(i)
g = num%i
if num%i == 0:
print(f'{num} divided by {i}')
num += 1
break
try:
print(f'Remainder {g}')
print(num)
except:
print(num)
num += 1
```

its dividng every non-prime number by 1 but not dividing prime number by 1 i am totally confused this is the most confusing problem i have ever faced in my coding journey pls help!!!