Exercise
Enhanced Triangle V2
Objective
Develop a Python program to prompt the user for their name and display a triangle with it, starting with 1 letter and growing until it has the full length:
Enter your name: Juan
J
Ju
Jua
Juan
Example Python Exercise
Show Python Code
# Prompt the user for their name
name = input("Enter your name: ")
# Loop through each character of the name and print increasing substrings
for i in range(1, len(name) + 1):
print(name[:i])
Output
Enter your name: Juan
J
Ju
Jua
Juan
Share this Python Exercise
Explore our set of Python Programming Exercises! Specifically designed for beginners, these exercises will help you develop a solid understanding of the basics of Python. From variables and data types to control structures and simple functions, each exercise is crafted to challenge you incrementally as you build confidence in coding in Python.
In this exercise, you will develop a Python program that prompts the user for their name and a size, and displays a hollow rectangle with it. This exercise is ...
In this exercise, you will develop a Python program that displays a centered triangle from a string entered by the user. This exercise is perfect for practicin...
In this exercise, you will develop a Python program to create a database for storing information about urban areas. In the first approach, you will store only the nam...
In this exercise, you will develop a Python program to mimic the basic Unix SysV "banner" utility, capable of displaying large texts. This exercise is perfect ...
In this exercise, you will develop a Python program that prompts the user for a string and displays a right-aligned triangle. This exercise is perfect for prac...
In this exercise, you will develop a Python program that prompts the user for a string and performs several transformations. The program will replace all lowercase 'a...