PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, September 16, 2022

[FIXED] How to add the new line without space after ',' in print() in Python

 September 16, 2022     newline, printing, python     No comments   

Issue

There is two data and printing the length of them. Code:

print(len(author),'\n',len(authorUnique))

and output:

5439 
 4443

I would like to get:

5439 
4443

What can I do to get what I want?


Solution

Don't print them at once! It's much simpler to split this up into two separate print statements, which also solves your problem:

print(len(author))
print(len(authorUnique))

If you do only want to use one print statement, however, you need to specify the right separator token, like this:

print(len(author), len(authorUnique), sep='\n')


Answered By - q9i
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,215,963

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing