Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print without newline in BASIC

In BASIC I know of two instructions to print to the screen, PRINT, and WRITE, both of which automatically print strings with a newline at the end. I want to print a string without a newline. How can I do this? I'm using GW-BASIC.

like image 997
MD XF Avatar asked May 06 '17 00:05

MD XF


People also ask

How do I print without line breaks?

To print without a new line in Python 3 add an extra argument to your print function telling the program that you don't want your next string to be on a new line. Here's an example: print("Hello there!", end = '') The next print function will be on the same line.

How do you print without next line in Python?

It is used to indicate the end of a line of text. You can print strings without adding a new line with end = <character> , which <character> is the character that will be used to separate the lines.

What is the use of \n in the print () function?

The Python print() function takes in python data such as ints and strings, and prints those values to standard out. To say that standard out is "text" here means a series of lines, where each line is a series of chars with a '\n' newline char marking the end of each line.

How do I show single line output in Python?

Modify print() method to print on the same line The print method takes an extra parameter end=” “ to keep the pointer on the same line. The end parameter can take certain values such as a space or some sign in the double quotes to separate the elements printed in the same line.


1 Answers

Using PRINT with a semicolon will not print a new line:

10 REM The trailing semicolon prevents a newline
20 PRINT "Goodbye, World!";

Source: Rosettacode

like image 148
Aurélien Gasser Avatar answered Sep 20 '22 23:09

Aurélien Gasser