based on that code, I wish to output my result by ending each digit with a dot.
input:
x = 0
while x<=5:
print(x)
x += 1
expected output:
1.
2.
3.
4.
5.
>Solution :
Make sure you start at x = 1 and add a full stop to the string. Concatenating more letters or symbols to variables can be done with f-strings:
# Start at 1
x = 1
while x <= 5:
print(f'{x}.')
x += 1
Alternatively, you could turn this into a one liner function:
>>> def ordered(start, stop):
... return '\n'.join(f'{x}.' for x in range(start, stop+1))
...
>>> print(ordered(1, 5))
1.
2.
3.
4.
5.