Python Forum
for x to y step from basic in Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
for x to y step from basic in Python
#3
first_value = 3940
second_value = 5630
last_in_loop = 200
start = 5
build_string = ""

while True:
    for count in range(start, last_in_loop, start) :
        build_string = build_string + 's' + str(first_value)
        first_value += start

    if first_value < second_value + start :
        build_string = ""
    else :
        break
Note that variables named a, b, x, etc are frowned upon as being nondescriptive. Much of the code is similar to Basic, the for loop is an exception, and a big one is that there is no "goto", true of most modern languages (hence the use of the
while
, which you exit with
break
.
Reply


Messages In This Thread
for x to y step from basic in Python - by lastyle - Aug-25-2020, 06:05 PM
RE: for x to y step from basic in Python - by jefsummers - Aug-25-2020, 08:26 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020