Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with assignment
#8
Little update:

def print_spruce(n):
       for i in range(1, n+1): 
              print (" " *(n-i) + "X"*(2*i-1))
              print (" " * (n-1) + "X")
n = int(input("Write the size of the spruce:"))
print_spruce(n)
terminal:
Write the size of the spruce:5
    X
    X
   XXX
    X
  XXXXX
    X
 XXXXXXX
    X
XXXXXXXXX
    X
So, what should I change?

I think this is the cloest to my goal:

def print_spruce(n):
       for i in range(1, n+1, 2): 
              print (" " *(n-i) + "X"*(2*i-1))
              print (" " * (n-1) + "X")
n = int(input("Write the size of the spruce:"))
print_spruce(n+1)
terminal:
Write the size of the spruce:5
     X
     X
   XXXXX
     X
 XXXXXXXXX
     X
So, where are the mistakes?
Reply


Messages In This Thread
help with assignment - by Mof44 - Nov-17-2018, 10:22 PM
RE: help with assignment - by Larz60+ - Nov-17-2018, 10:37 PM
RE: help with assignment - by Mof44 - Nov-17-2018, 10:44 PM
RE: help with assignment - by ichabod801 - Nov-17-2018, 11:19 PM
RE: help with assignment - by Mof44 - Nov-18-2018, 06:22 AM
RE: help with assignment - by buran - Nov-18-2018, 08:03 AM
RE: help with assignment - by Mof44 - Nov-18-2018, 08:31 AM
RE: help with assignment - by Mof44 - Nov-18-2018, 10:17 AM
RE: help with assignment - by ichabod801 - Nov-18-2018, 04:26 PM
RE: help with assignment - by Larz60+ - Nov-18-2018, 11:58 PM

Forum Jump:

User Panel Messages

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