- 1
Find me in Traingle
Create a triangle pattern consisting of random numbers..... and then search a particular number and print the output if present or not
2 Réponses
+ 3
Show us what you‘ve tried, so we can give you tips…
But in general just iterate trough your numbers and check if its the number you search for… Or add the numbers into a list and check if your searched is in it
0
import random
n= random.randint(0,100)
h=int(input("Enter the height of the triangle: "))
output=' '
for i in range(h):
print((output*(h-i-1))+((str(random.randint(0,50))+' ')*(i+1)))
so I have tried this code though it'snot the correct one to genrate triangle consisting of random numbers