For, while

Asked 2 years ago, Updated 2 years ago, 440 views

For statement

hap=0
for n in range(1234,4568):
    if n%444 ==0:
        hap += n
print(hap)

How do I change this to a while statement

for while-loop python

2022-10-18 09:01

1 Answers

hap=0
n=1234
while n<4568:
    if n%444 ==0:
        hap += n
    n+=1
print(hap)

You can do it like this.


2022-10-18 09:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.