I'm fairly new to programming, i have to start learning it for Uni.
I have to make a pattern as follow:
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
I have found ample examples of code for these patterns, just not for mine.
I cannot seem to get the numbers to line up vertically, only underneath each other:
5
4
3
2
1
4
3
2
1
what am i Missing ? I can't seem to find the exact function that other people are using to make their code act like this.
# Question 4.
import random
num1 = random.choice([5, 6, 7, 8, 9, 10])
def print_triangle():
for row in range(num1, 0, -1):
for space in range(num1 - row):
print ('')
for col in range(row, 0, -1):
print (col)
print_triangle()