Python Forum
How to remove empty line between two print functions
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to remove empty line between two print functions
#1
Hello,

I'm new to python and this is my first post.

I'm trying to write a function that would need me to print a triangle made of "*"s

Here is my program:

# Type your code here

n = int(input("Enter a positive integer greater than or equal to 3: "))

count = 1
star = "*"
for x in range(0, n):
    print(star*count)
    count += 1
print()

count_ = n-1
star_ = "*"
for a in range(0,n-1):
    print(star_*count_)
    count_ -= 1
print()
When I print it for the value of 6, I get the following:

Output:
Enter a positive integer greater than or equal to 3: 6 * ** *** **** ***** ****** ***** **** *** ** *
My question is, how do I remove that empty line between where the first function ends and the new one begins?

I apologize if this is a really easy fix, but I have only been coding for 1 week now. So I could use all the help I can get.

Thank you!!
Reply
#2
well. remove the print() on line 10
also note that you don't have any functions in your code. That said - you may want to refactor your code with using function to avoid repetative code
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  problem with spliting line in print akbarza 3 375 Jan-23-2024, 04:11 PM
Last Post: deanhystad
  Print the line before the corrent line tester_V 9 1,553 Nov-18-2022, 08:39 AM
Last Post: Gribouillis
  Remove a space between a string and variable in print sie 5 1,776 Jul-27-2022, 02:36 PM
Last Post: deanhystad
  Print to a New Line when Appending File DaveG 0 1,217 Mar-30-2022, 04:14 AM
Last Post: DaveG
  help with commas in print functions kronhamilton 11 3,419 Feb-10-2022, 02:02 PM
Last Post: mishraakash
  Remove empty keys in a python list python_student 7 3,013 Jan-12-2022, 10:23 PM
Last Post: python_student
  If match not found print last line tester_V 2 2,882 Apr-26-2021, 05:18 AM
Last Post: tester_V
  print a line break in writelines() method leodavinci1990 1 6,443 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,020 Oct-10-2020, 10:00 PM
Last Post: bowlofred
  How to print string multiple times on new line ace19887 7 5,722 Sep-30-2020, 02:53 PM
Last Post: buran

Forum Jump:

User Panel Messages

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