+ 2
What is the missing
This is how the output The number are: 2,4,6,8,10,12,14,16,18 https://code.sololearn.com/c0rcQ9NZ0M28/?ref=app
28 Answers
+ 10
https://code.sololearn.com/cE4YY83k45Ti/?ref=app
Instead of greater than you used less than in if condition..
+ 5
print("The number are: ")
x=0
while x<18:
x+=2
if x<18:
print (x,end=",") #end=', ' adds comma at end instead of \n new line (default case)..
else:
print(x)
#Bacani Rocelle M. you can put into a list then print print list after loop..
#you can code this simply
for n in range(2, 18+1, 2) : print(n, end=', ' )
#or
print( *range(2, 20,2), sep=' ,' )
+ 2
x=f=0
while x<18:
x+=2
if x==f+2: print(f"The numbers are: {x}", end="")
else: print (f", {x}", end="")
else:
print("\nIt is the end result that counts")
+ 2
various ways:
1) by uding format method
print("{0},{1}".format("a","b")) #{0} position is replaced by "a", and {1} is replaced by nexr argument
2) by ising fstrings like
x=2
y=3
print(f"{x},{y}") #{x} will be replaced by its value
other ways may be by fstring used most, has many features..
+ 2
x=0
while x<18:
print("The number are: ")
x+=2
if x<18:
print (x,",")
else:
print(x)
Your indentation were faulty
+ 1
Bacani Rocelle M. Put print statement print('The numbers are before loop') #not in loop.
+ 1
Jayakrishna🇮🇳 yep i already do that but the numbers are down
+ 1
Thanks a lot
+ 1
You forgot about tabs. The code is read like there was no if-else statement. You can also take "The numbers are" print command out of the loop to output it once.
+ 1
Indentation error are there correct the last 3lines after that it's perfect...:)
+ 1
Thank a lot guys for answering my question
+ 1
x=0
while x<=18:
if x%2==0:
print("The number are: "+str(x))
x+=1
0
Riya but the output is not the same what i need to change
0
SoloProg can you explain me a little bit about this its like complicated for me
0
Jayakrishna🇮🇳 how to put the numbers beside the string
0
I know na thanks a lott
0
x=0
while x<18:
print("The number are: ")
x+=2
if (x<15):
print(x)
else:
print(x)
0
💪