Python Practice › String Programs › Program 81

Remove symbols and capitalise

EasyString Programs · 81 of 106

Write a Python program to remove unwanted characters from a string and capitalise it.

Advertisement
Input
"sqa****too^^{ls"
Output
Sqatools

Approach

  1. Keep letters only, then capitalize().

Solution

Python
text = "sqa****too^^{ls"print("".join(ch for ch in text if ch.isalpha()).capitalize())
Output
Sqatools

Learn the concept

New to this topic? Read the lesson, then come back.

More string programs

← All 106 String Programs

Leave a Comment