- 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

5th Jun 2022, 11:21 AM
DEMETRIUS NDIBALEMA
DEMETRIUS NDIBALEMA - avatar
4 Answers
+ 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
5th Jun 2022, 1:34 PM
Lothar
Lothar - avatar
+ 3
There's no errors
5th Jun 2022, 11:30 AM
Rupali Haldiya
Rupali Haldiya - avatar
+ 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')
5th Jun 2022, 11:31 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
thanks
5th Jun 2022, 11:37 AM
DEMETRIUS NDIBALEMA
DEMETRIUS NDIBALEMA - avatar