- 1
What is wrong with this code? x = 0 while x< 9: x+=1 print(x,'''.\n''')
python programming seeking to get a solution in python beginer project
4 Antworten
+ 5
i think that the task is from 'python for beginners' (lesson nr 13):
The program needs to output the numbers 1 to 9, each on a separate line, followed by a dot. there are various possible solutions, one could be:
(for future questions: please mention the tutorial and the lesson name / number)
x = 1 # should start with value of 1
while x <= 9: # as the task description says, we should output numbers from 1 upto 9, so we need ... x <= 9
#x+=1 # better do this after the output
print(x, ".", sep="") # sep avoids using a space between the number and the dot. >>> no need to use '\n', since this creates an additional (not required) line feed / new line
x += 1 # increment the loop counter
+ 3
There's no errors
+ 3
DEMETRIUS NDIBALEMA
I am not sure of your output requirements, but I would suggest this:
x = 0
while x< 9:
x+=1
print(str(x)+'.\n')
+ 1
thanks