Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print a linebreak in a python function?

I have a list of strings in my code;

A = ['a1', 'a2', 'a3' ...] B = ['b1', 'b2', 'b3' ...] 

and I want to print them separated by a linebreak, like this:

>a1 b1 >a2 b2 >a3 b3 

I've tried:

print '>' + A + '/n' + B 

But /n isn't recognized like a line break.

like image 683
Geparada Avatar asked May 12 '11 17:05

Geparada


People also ask

How do you show spaces in Python?

Python isspace() method is used to check space in the string. It returna true if there are only whitespace characters in the string. Otherwise it returns false. Space, newline, and tabs etc are known as whitespace characters and are defined in the Unicode character database as Other or Separator.

How do you print a variable in Python?

You first include the character f before the opening and closing quotation marks, inside the print() function. To print a variable with a string in one line, you again include the character f in the same place – right before the quotation marks.


2 Answers

You have your slash backwards, it should be "\n"

like image 100
Winston Ewert Avatar answered Oct 01 '22 11:10

Winston Ewert


The newline character is actually '\n'.

like image 31
zeekay Avatar answered Oct 01 '22 12:10

zeekay