1 ImportSYS2 3 4 defcount_holes (letter):5hole_2 = ['A','D','O','P','Q','R']6 ifLetter = ='B':7 return28 elifLetterinchhole_2:9 return1Ten Else: One return0 A - - defMain (): then =Int (sys.stdin.readline ()) - forTinchSys.stdin: -num =0 - forLinchT[:-1]: +num + =count_holes (L) - PrintNum + A atMain ()
Learn
Raw_input () and sys.stdin.readline () differences
Raw_input () does not contain the last \ n line-break symbol, and the latter has
Sys.stdin.readline (). Strip (), no parameters, default strip trailing, newline
. spilt () plus one, according to the space, the input data is divided
Ide
The understanding of Debug
Console input cannot be immediately echoed
Because the pycharm enabled buffering, in order to efficiently
Psyco.full ()
Sometimes it does cause re
Good code indentation and whitespace
Pre-defined way faster
If a in b[]
For loop
No problem, you can loop a string, if you do not want \ n (the subject does not affect the result, but more than once the function call), with [:-1], this: operation is py a great advantage
This idea and commissioning are done independently.
Come on!
Error
Elif (' A ' or ' D ' or ' O ' or ' P ' or ' Q ' or ' R ') = = Letter: Logical judgment is wrong, cannot judge a after, cannot use
Holes in the text Add problem to Todo list problem code:holes