Holes in the text Add problem to Todo list Problem code: HOLES, holestodo

Source: Internet
Author: User

Holes in the text Add problem to Todo list Problem code: HOLES, holestodo

 1 import sys 2  3  4 def count_holes(letter): 5     hole_2 = ['A', 'D', 'O', 'P', 'Q', 'R'] 6     if letter == 'B': 7         return 2 8     elif letter in hole_2: 9         return 110     else:11         return 012 13 14 def main():15     n = int(sys.stdin.readline())16     for t in sys.stdin:17         num = 018         for l in t[:-1]:19             num += count_holes(l)20         print num21 22 23 main()

 

 

Learning

Raw_input () and sys. stdin. readline ()

Raw_input () does not contain the last line break of \ n, while the latter has

Sys. stdin. readline (). strip (), no parameter. By default, spaces and line breaks are removed.

. Spilt () and separate the input data by space.

IDE

Debug Comprehension

Console input cannot be displayed immediately

Because pycharm enables buffering

Psyco. full ()

Sometimes it does cause RE

Good code indentation and spaces

Predefined mode is faster

If a in B []

For Loop

No problem. You can use a loop String. If you do not want \ n (this question does not affect the result, but multiple functions are called), use [:-1: the operation is a great benefit of py.

Both the conception and debugging are independently completed.

Come on!

Error
Elif ('A' or 'D' or 'O' or 'P' or 'q' or 'R') = letter: the logical judgment is wrong, unavailable

  

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.