134. Python Program to Print a Triangle Using a Function with Parameters
MediumArguments
Overview
Combine a default value, a keyword argument and a loop.
Problem Statement
Write a function print_row(count, symbol="*") that prints symbol repeated count times on one line.
Then read a size (a whole number) and a base symbol (one character), one per line. Use your function to print:
- A triangle of stars: rows of 1, 2, 3 … up to
sizestars. Use the default symbol for these. - A base: one row of
sizecopies of the base symbol.
For example, for size 3 and base symbol -:
*
**
***
---
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
One value per line, in this order: the size, then the base symbol. Example:
3\
Output
The triangle and base shown above.
The tests try 3 different inputs.