Put it inside of the quotes:
Number = raw_input("Enter a number\n")
\n is a control character, sort of like a key on the keyboard that you cannot press.
You could also use triple quotes and make a multi-line string:
Number = raw_input("""Enter a number
""")
Answer from Blender on Stack OverflowPut it inside of the quotes:
Number = raw_input("Enter a number\n")
\n is a control character, sort of like a key on the keyboard that you cannot press.
You could also use triple quotes and make a multi-line string:
Number = raw_input("""Enter a number
""")
If you want the input to be on its own line then you could also just
print "Enter a number"
Number = raw_input()
Use newlines \n with the command python -c
How would I make the output make a new line after each output?
How do i get new lines in a text file if the variables are an input type
How to add newline to Python file that will print as such in string?
\n already does render as a newline in both situations. And it already doesn’t in both situations.
That’s confusing, so I’ll try to explain. \n isn’t a special character within a string. When you look at strings (either by looking at the string in Python, or by opening the file you were talking about in an editor), you can see \n right there in the middle of the line, no newline at all.
What \n is however, is a printer control character. It doesn’t mean anything special to a string datatype, but it does mean something to a printer, such as your terminal STDOUT, or Python’s print() command. If you print() the string within Python you’ll see a line break, because \n is only interpreted as something special when printing.
Videos
I'm new to coding in general and i'm making a little program that you put in a number and it tells you what change it would be. so 50 would be 2 quarters. This is an example of how it looks like for quarter:
if Num_Quarters > 0: print(Num_Quarters, end=" ") if Num_Quarters == 1: print("Quarter", end=" ") else: print("Quarters", end=" ")
This works just fine but if it has more than one output such as nickels it will write it in one line like '2 quarters 1 nickel' when I want the nickels to be on its own line below it. From my understanding the way to make a new line is to incorporate \n: but when I do I just get errors. I might be putting it in the wrong spot? Any help is appreciated