Challenge 3: Print a Right-Angled Triangle
This challenge will test your knowledge of nested for loops.
We'll cover the following
Problem Statement
Write a code which prints a right-angled triangle of the character &
.
The code takes an integer variable row as input and prints the right-angled triangle with that number of rows displaying &
.
The base of the right-angled triangle is the input number, i.e., input of n will yield a triangle of base n
Input
positive integer
Output
right-angled triangle
Sample Input
5
Sample Output
&
&&
&&&
&&&&
&&&&&
Coding Exercise
Write your code below. It is recommended​ that you try solving the exercise yourself before viewing the solution.
Note: There is a
test
function given in the code for testing purposes. Do not modify it.
Good luck! 🤞
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy