Answer to Question #178322 in Python for nun

Question #178322

smartphone_brand = ‘Samsung Galaxy S20’ Write a program to find the number of uppercase, lowercase, and numbers in the value assigned to the variable smartphone_brand above. Make sure to use the loop concept to answer the question.


1
Expert's answer
2021-04-05T04:22:17-0400
#!/usr/bin/env python
import string
smartphone_brand = 'Samsung Galaxy S20'
num_upper = 0
num_lower = 0
num_digit = 0

for ch in smartphone_brand:
    if ch in string.ascii_lowercase:
        num_lower += 1
    elif ch in string.ascii_uppercase:
        num_upper += 1
    elif ch in string.digits:
        num_digit += 1

print(f'Threre are {num_upper} uppercase, {num_lower} lowercase and {num_digit} digit')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS