4
I’m solving an exercise that asks me to enter a value for example: 5 and print the first 5 natural odd numbers in the case:
entree:
Enter the value of n: 5
- 1
- 3
- 5
- 7
- 9
The code I wrote works but it does not seem to me the best logic for solving it. Would anyone know any other "simple" solution because I’m still learning
n = int(input("Digite o valor de n: "))
i = 1
while i <= (n+n):
if i % 2 != 0:
print(i)
i += 1
else:
i += 1
Thanks bro @Mathias
– WSS