+ 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

12th Dec 2022, 7:44 AM
Bacani Rocelle M.
Bacani Rocelle M. - avatar
27 Réponses
+ 10
https://code.sololearn.com/cE4YY83k45Ti/?ref=app Instead of greater than you used less than in if condition..
12th Dec 2022, 7:50 AM
Riya
Riya - avatar
+ 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=' ,' )
12th Dec 2022, 8:42 AM
Jayakrishna 🇮🇳
+ 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")
12th Dec 2022, 8:35 AM
SoloProg
SoloProg - avatar
+ 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..
12th Dec 2022, 10:19 AM
Jayakrishna 🇮🇳
+ 2
x=0 while x<18: print("The number are: ") x+=2 if x<18: print (x,",") else: print(x) Your indentation were faulty
12th Dec 2022, 5:25 PM
Justice Friday
Justice Friday - avatar
12th Dec 2022, 8:12 AM
Bacani Rocelle M.
Bacani Rocelle M. - avatar
+ 1
Bacani Rocelle M. Put print statement print('The numbers are before loop') #not in loop.
12th Dec 2022, 8:12 AM
Jayakrishna 🇮🇳
+ 1
Jayakrishna🇮🇳 yep i already do that but the numbers are down
12th Dec 2022, 8:13 AM
Bacani Rocelle M.
Bacani Rocelle M. - avatar
+ 1
Thanks a lot
12th Dec 2022, 8:49 AM
Bacani Rocelle M.
Bacani Rocelle M. - avatar
+ 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.
12th Dec 2022, 2:36 PM
tnaa
tnaa - avatar
+ 1
Indentation error are there correct the last 3lines after that it's perfect...:)
13th Dec 2022, 6:08 AM
Soumya Ranjan Behera
Soumya Ranjan Behera - avatar
+ 1
Thank a lot guys for answering my question
13th Dec 2022, 6:16 AM
Bacani Rocelle M.
Bacani Rocelle M. - avatar
+ 1
x=0 while x<=18: if x%2==0: print("The number are: "+str(x)) x+=1
13th Dec 2022, 1:41 PM
Reza
Reza - avatar
0
Riya but the output is not the same what i need to change
12th Dec 2022, 7:55 AM
Bacani Rocelle M.
Bacani Rocelle M. - avatar
0
SoloProg can you explain me a little bit about this its like complicated for me
12th Dec 2022, 8:40 AM
Bacani Rocelle M.
Bacani Rocelle M. - avatar
0
Jayakrishna🇮🇳 how to put the numbers beside the string
12th Dec 2022, 8:52 AM
Bacani Rocelle M.
Bacani Rocelle M. - avatar
0
I know na thanks a lott
12th Dec 2022, 10:20 AM
Bacani Rocelle M.
Bacani Rocelle M. - avatar
0
x=0 while x<18: print("The number are: ") x+=2 if (x<15): print(x) else: print(x)
12th Dec 2022, 2:52 PM
Amredin Seid
0
💪
12th Dec 2022, 3:06 PM
KONDJEE KAMUTIND
12th Dec 2022, 4:03 PM
Nathaniel Yebuah
Nathaniel Yebuah - avatar