Answer:
i= 1
for i in range(1,n):
if i * i < n:
print(2* i + 1)
i += 1
else:
print('Hakuna Matata')
Explanation:
First, there's a need to rewrite the code segment in your question (because of indentation)
<em>i= 1</em>
<em>while i*i < n:</em>
<em> print(2* i + 1)</em>
<em> i += 1</em>
<em>else:</em>
<em> print('Hakuna Matata')</em>
<em />
The explanation of the equivalent of the above while loop is as follows
This line initializes i to 1
i= 1
This line iterates from 1 to n-1
for i in range(1,n):
This line checks if i * i is less than n
if i * i < n:
The following line is executed if the above condition is satisfied; otherwise, nothing is done
print(2* i + 1)
The value of i is incremented by 1 using this line
i += 1
The following is executed at the end of the iteration
else:
print('Hakuna Matata')
<em>Note: Assume any value of n, both programs display the same output</em>