I have a piece of code in Pycharm , and I want to loop just a part of it, not with the beginning part where are located the login info. Let's say that I want to loop from the 44 line to 99 and only for 20 loops.
closed as off-topic by Niels van Reijmersdal, NarendraC, Ray Oei, alecxe♦ Mar 25 at 14:29
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions about software development unrelated to testing are off-topic here, but can be asked on Stack Overflow." – Niels van Reijmersdal, NarendraC, Ray Oei, alecxe
start = 1 multiply = start * 2 divided = multiply / 3
Now, let's say you want to multiply by two 20 times:
start = 1 multiply = multiply_value(value = start, number_of_times = 20) divided = multiply / 3 def multiply_value(value, number_of_times): if(number_of_times <= 0): return value else: return multiply_value(value * 2, number_of_times - 1)
Alternatively, you could use a for loop:
def multiply_value(value, number_of_times): result = 1 for i range(0, number_of_times): result = result * 2 return result
I suggest reading the section 4 of this Learn X in Y Minutes page.