how to search for a capital letter within a string and return the list of words with and without capital letters

前端 未结 9 1203
无人共我
无人共我 2020-12-18 23:23

My homework assignment is to Write a program that reads a string from the user and creates a list of words from the input.Create two lists, one containing the words that con

9条回答
  •  情书的邮戳
    2020-12-18 23:43

    Try doing the following:

    1. Split the string into a list where each item is a separate word.
    2. For every word in that list, iterate through and check for capital letters (consider the string constants such as string.uppercase). If it has a capital letter, insert it onto the front of your result list. If not, append it to the end of your result list.
    3. Iterate through your results, printing them. Or, if you want to avoid iterating, join the items in the string using the newline character \n.

提交回复
热议问题