Python Exercise: Sequence of lines as input and prints the lines as output in lower case
Python Conditional: Exercise-12 with Solution
Write a Python program that accepts a sequence of lines (blank line to terminate) as input and prints the lines as output (all characters in lower case).
# Create an empty list named 'lines' lines =  # Continue to prompt the user for input indefinitely until a blank line is entered while True: # Prompt the user to input a line of text l = input() # Check if the entered line is not empty (non-empty string) if l: # Convert the entered line to uppercase and append it to the 'lines' list lines.append(l.upper()) else: # If the entered line is empty, break out of the loop break; # Iterate through each line in the 'lines' list for l in lines: # Print each line (converted to uppercase) from the 'lines' list print(l)
w3resource Python W3RESOURCE PYTHON
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program which takes two digits m (row) and n (column) as input and generates a two-dimensional array. The element value in the i-th row and j-th column of the array should be i*j.
Next: Write a Python program which accepts a sequence of comma separated 4 digit binary numbers as its input and print the numbers that are divisible by 5 in a comma separated sequence.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join