num = int(input("Enter your number: "))
for i in range (1, num+1):
if (i%2==0):
i = i // 2
print(3**(i-1))
else:
i = i // 2 + 1
print(2**(i-1))
TO
num = int(input("Enter your number: "))
i=1
j=1
while j<=num and i<=num:
if (i%2==0):
i = i // 2
print(3**(i-1))
else:
i = i // 2 + 1
print(2**(i-1))
j+1
Facing problem in while loop conversion.
Searched this problem everywhere on the internet but unable to solve it.
j?jis not being incremented within thewhileloop, so it will never satisfy your conditions.ivalue get changed when it enters inside the loop. So usedj. Not able to find a way of incrementing the value ofi.jwithin the loop and you will need to usej += 1