mercredi 27 septembre 2023

My right angle pattern is incomplete, why am I missing a few bottom rows or columns?

I am close to figuring out this code but it keeps resulting in a missing bottom line.

The pattern is supposed to be like this:

🐟
🐟🐟
🐟🐟🐟
🐟🐟
🐟

My code:
def get_right_arrow_pattern(max_cols)
    emoji = "🐟"
    result = ""
    max_rows = max_cols
    for row in range(1, max_rows+1):
        for column in range(1, max_cols+1):
            result = "" + result
        result += str(emoji)
        print(result)
    return emoji

Output:
🐟
🐟🐟
🐟🐟🐟
🐟🐟🐟🐟
🐟
None

The trick is I can't use print() within the function or for loop but it's giving me a semi-result of what I need. Any suggestions?

Aucun commentaire:

Enregistrer un commentaire