Reputation: 3
I have the following FORTRAN Code which I want to rewrite in Python:
2 continue
statement 1
statement 2
do 1 j=1, 10
statement 3
statement 4
1 continue
if a .lt. 5 go to 2
Does anyone have an elegant way of implementing this structure in python?
Upvotes: 0
Views: 685
Reputation: 471
You can try using something similar to the following:
while True:
statement 1
statement 2
for i in range(1,11):
statement 3
statement 4
if a >= 5:
break
Upvotes: 1
Reputation: 123
The transformation can be straightforward. Here I am assuming that you can change 'a' at the beginning so that the 'while' condition is satisfied initially. Something like
a = 0
while a < 5:
statement 1
statement 2
# 'do 1 j=1, 10' will include 10, right? Not so in Python
for i in range(1, 11):
statement 3
statement 4
Upvotes: 0