Python Forum
If-Print statements on the same line
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If-Print statements on the same line
#1
How do you suggest I make it so that the two print statements are on the same line?

ph = float(input('Enter ph:'))
if ph < 7.0
    print('It\'s acidic.')
    if ph < 4.0
        print('It\'s a strong acid.')
Thanks
Reply
#2
print() has optional argument end argument
print('It\'s acidic.', end=' ')
or

ph = float(input('Enter ph:'))
if ph < 7.0
    print('It\'s acidic.', end='')
    if ph < 4.0
        print(' It\'s a strong acid.')
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  problem with spliting line in print akbarza 3 388 Jan-23-2024, 04:11 PM
Last Post: deanhystad
  Print the line before the corrent line tester_V 9 1,575 Nov-18-2022, 08:39 AM
Last Post: Gribouillis
  print statements without () petec 7 2,007 Jun-17-2022, 02:27 AM
Last Post: snippsat
  Print to a New Line when Appending File DaveG 0 1,223 Mar-30-2022, 04:14 AM
Last Post: DaveG
  If match not found print last line tester_V 2 2,889 Apr-26-2021, 05:18 AM
Last Post: tester_V
  print a line break in writelines() method leodavinci1990 1 6,466 Oct-12-2020, 06:36 AM
Last Post: DeaD_EyE
  Print characters in a single line rather than one at a time hhydration 1 2,035 Oct-10-2020, 10:00 PM
Last Post: bowlofred
  How to print string multiple times on new line ace19887 7 5,758 Sep-30-2020, 02:53 PM
Last Post: buran
  Pattern Require Last Line Print() why? Harshil 4 2,437 Aug-08-2020, 04:54 PM
Last Post: Harshil
  Unable to combine print statements in for loop adeana 2 1,997 Jun-12-2020, 05:08 PM
Last Post: adeana

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020