Python Code for Pattern Printing: How to repeat numbers in custom sequence

ANSHPREET
By -
0
Code Snippet with Copy and Run Button
def printPattern(num, limit):
    for i in range(1, limit + 1):
        print(str(num) * i)

if __name__ == "__main__":
    try:
        num = int(input("Enter a number to repeat: "))
        limit = int(input("Enter the limit for the pattern: "))
        printPattern(num, limit)
    except ValueError:
        print("Please enter valid numbers.")
Tags:

Post a Comment

0Comments

Post a Comment (0)
Loading {title}...