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)