Outputs special character cascades using Python functions

Asked 2 years ago, Updated 2 years ago, 42 views

It outputs special characters as many as the number of rows, and parameter 1 uses superposition for statement to output special characters parameter 2 How should I make a function code to enter the number of lines?

num=int(input())
num2=int(input())
a = input()
for i in range(num):
    for j in range(num2):
        if j <= i:
            print(a,end='')
    print()

I made it like this

python function

2022-09-20 10:22

1 Answers

num = int(input())
a = input()


def steps(a, num):
    for i in range(num):
        for j in range(num):
            if j <= i:
                print(a, end="")
        print()


steps(a, num)


2022-09-20 10:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.