Home > other >  Strives for the correct procedure
Strives for the correct procedure

Time:09-18

I want to know the statistics of lowercase letters and Numbers of digital text file where program error, is to find logic where is wrong, for bosses to help point out correct, thank

CodePudding user response:

1. Variable is initialized in the beginning of the program
2. The judgment of character types in the while loop body
3. F.r ead into variable s () to read once, don't read twice in a loop

CodePudding user response:

What you write is determine what is the last one, to be placed inside a loop for judgment

CodePudding user response:

 "" "is suitable for small open file "" "
Isupper_count=0
Islower_count=0
Isdigit_count=0
With the open (" Exp030202. TXT ", "r") as f:
String=f.r ead ()

For I in string:
If i.i supper () :
Isupper_count +=1
If i.i slower () :
Islower_count +=1
If i.i sdigit () :
Isdigit_count +=1

Print (" capital letters with % s "% isupper_count)
Print (" lowercase letters have % s "% islower_count)
Print (" digital character with % s "% isdigit_count)

CodePudding user response:

reference 1st floor chuifengde response:
1. Variables are initialized in the beginning of the program
2. The judgment of character types in the while loop body
3. F.r ead into variable s () to read once, don't read twice in a loop

Understand, thank you

CodePudding user response:

refer to the second floor weixin_45903952 response:
you wrote just judge what is the last one, to be placed inside a loop judgment to

Thank you, has been corrected

CodePudding user response:

reference goofs off explode reply: 3/f
 "" "is suitable for small open file "" "
Isupper_count=0
Islower_count=0
Isdigit_count=0
With the open (" Exp030202. TXT ", "r") as f:
String=f.r ead ()

For I in string:
If i.i supper () :
Isupper_count +=1
If i.i slower () :
Islower_count +=1
If i.i sdigit () :
Isdigit_count +=1

Print (" capital letters with % s "% isupper_count)
Print (" lowercase letters have % s "% islower_count)
Print (" digital character with % s "% isdigit_count)


Thank you for your code, it is very clear
  • Related