Example: python: How do I write a function that capitalizes a name and becomes the following?
Dictionaries + lists: Each letter is in a list of dictionaries, divided six times to print out:
DIC = {}dic[' c ']=[' CCCC ', ' C c ', ' C ', ' C ', ' C c ', ' CCCC ']dic[' a ']=[' a ', ' a ' ',' A ', ' aaaaaaa ', ' a a ', ' a ']dic[' t ']=[' ttttttt ', ' t ', ' t ', ' t ', ' t ', ' t ']dic[' r ']=[' rrrrr ', ' r r ', ' R R ', ' Rrrrr ', ' R R ', ' r r ']dic[' e ']=[' eeeeee ', ' e ', ' eeee ', ' e ', ' e ', ' eeeeee ']for count in range (6 ): Print dic[' C '][count],print dic[' A '][count],print dic[' T '][count],print dic[' E '][count],print dic[' R '][count]
Error attempt: If you consider Carter five characters as four key-value pairs and enclose them in a dictionary with three quotes, you can only output one column vertically. The code is as follows:
DIC = {}dic[' c ']= ' ' CCCC c CCC c C CCCC ' ' dic[' a ']= ' a A a ' a aaaaaaa ' A a A A ' dic[' t ']= ' ttttttt t t t t t ' dic[' R ']= ' ' rrrrrr rr rrrrrrr RR
This code prints out the result isCater this is caused by a newline character that is output in three quotes.
Copyright NOTICE: Welcome reprint, Reprint please indicate the source http://blog.csdn.net/ztf312/
Python: How to write a function to capitalize the name and change it to the following--dictionary with three quotation marks