🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
1. Introduction
Counting the number of lowercase characters in a string is a task that can be used to assess text complexity, readability, or adherence to style guides. Python, with its powerful string methods, makes this task simple.
A lowercase character is any alphabetical character presented in lowercase form, as opposed to uppercase (capital letters). In Python, the islower() method is used to check if a character is a lowercase.
2. Program Steps
1. Define a string to analyze.
2. Initialize a count variable to zero.
3. Loop through each character in the string, checking if it is lowercase.
4. Increment the count if a lowercase character is found.
5. Display the count of lowercase characters in the string.
3. Code Program
# Define the string
input_string = "Python is Fun to Learn!"
# Initialize the lowercase character counter
lowercase_count = 0
# Loop through each character and check if it's a lowercase letter
for char in input_string:
if char.islower():
lowercase_count += 1
# Print the number of lowercase characters
print(f"The number of lowercase characters is: {lowercase_count}")
Output:
The number of lowercase characters is: 14
Explanation:
1. input_string is assigned with the text "Python is Fun to Learn!".
2. lowercase_count is our counter, starting at 0.
3. A for loop iterates over each char in input_string.
4. The if statement uses the islower() string method to check if char is a lowercase character.
5. If char.islower() evaluates to True, lowercase_count is incremented by 1.
6. Once the loop completes, lowercase_count contains the total count of lowercase characters in input_string.
7. The print statement displays the result, which indicates there are 14 lowercase characters in the given input_string.
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business
Comments
Post a Comment
Leave Comment