capitalize all letters - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: capitalize all letters (/thread-6695.html) |
capitalize all letters - atux_null - Dec-03-2017 hi. i have a text and i need to get all first letters/numbers of each word, capitalize and put a dot after each one. the text='''kldjsh sdfbdb dbsd 67 dshss''' one=[x[0] for x in text.strip() ] print(one)with the above code i did manage to get the first letter of each word but i miss the upper case, the dot and a space after each word. some help please? i tried print(one.upper())but it returns error. RE: capitalize all letters - Larz60+ - Dec-03-2017 text = text.title() RE: capitalize all letters - atux_null - Dec-03-2017 OK i got all the first letters in capital, but i have them in between apostrophes '. I would like them to be without apostrophe. eg if the letters are NHJUI4G then have them as in the following format: N. H. J. U. I. 4. G. how do i fix that please? RE: capitalize all letters - buran - Dec-03-2017 use str.join() RE: capitalize all letters - atux_null - Dec-03-2017 (Dec-03-2017, 06:27 PM)buran Wrote: use str.join()sorry i've lost you on how to use it in my program. RE: capitalize all letters - buran - Dec-03-2017 >>> my_list = ['N', 'H', 'J', 'U', 'I', '4', 'G'] >>> '.'.join(my_list) 'N.H.J.U.I.4.G' >>> |