What is the Python logic to count the number of capital letters in a file

0 votes

Can anyone explain how to count the number of capital letters in a file?

Jun 26, 2020 in Python by Gitika
• 65,930 points
778 views

1 answer to this question.

0 votes

Hi,

You can use this piece of code, I hope this will help you:

import os

 os.chdir('C:\\Users\\lifei\\Desktop')

 with open('Today.txt') as today:

count=0

for i in today.read():

if i.isupper():

count+=1

print(count)
answered Jun 26, 2020 by Roshni
• 10,480 points

Related Questions In Python

0 votes
1 answer

What is the logic to check if a number is prime or not in python?

n = int (input ('ENTER NUMBER TO ...READ MORE

answered Jul 16, 2020 in Python by amrut
• 240 points
198 views
0 votes
2 answers

What is the python logic to check if a number is armstrong number or not?

a = int (input('enter number')) num = a sum ...READ MORE

answered Jul 16, 2020 in Python by amrut
• 240 points
259 views
0 votes
1 answer

What is the meaning of “int(a[::-1])” in Python?

Assumming a is a string. The Slice ...READ MORE

answered Aug 27, 2018 in Python by Priyaj
• 58,120 points
1,137 views
0 votes
1 answer

What is the recommended way to randomize a list of strings using Python?

Hi. Nice question. Here is the simplified answer ...READ MORE

answered Jan 18, 2019 in Python by Nymeria
• 3,520 points
229 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,249 views
0 votes
0 answers
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,810 points
1,684 views
+1 vote
8 answers

Count the frequency of an item in a python list

To count the number of appearances: from collections ...READ MORE

answered Oct 18, 2018 in Python by tinitales
23,178 views
+1 vote
7 answers