how to use the upper() - 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: how to use the upper() (/thread-5238.html) |
how to use the upper() - King - Sep-24-2017 How do i write a program, that asks the user for two strings, and proceeds to replace all occurrences of the second string in the first string with their uppercase versions. Example output enter first string: i want this item enter second string: i Replaced string: I want thIs Item RE: how to use the upper() - buran - Sep-24-2017 What have you tried? We are here to help, not to do your homework for you.... RE: how to use the upper() - King - Sep-24-2017 st1 = raw_input("Enter the first word: ") st2 = raw_input("Enter the second word: ") n = st2 print n.upper() I can't seem to make the whole sentences read. it only outputs I RE: how to use the upper() - Sagar - Sep-24-2017 In simple words I am explaining you how to solve this problem. 1. Input first sentence from the user. 2. Input second word from the user. 3. Find the word in the sentence. 4. Replace them with uppercase word. RE: how to use the upper() - Saka - Sep-26-2017 (Sep-24-2017, 12:19 PM)King Wrote: How do i write a program, that asks the user for two strings, and proceeds to replace all occurrences of the To get me understanding this, so basically you want to strings and all occurrences of string B in string A to be capitalized? So for example: A = abc123testfoobartest123bcawhat B = test Result = abc123TESTfoobarTEST123bcawhat Like that, right? Here's a little "function pack" for you:
RE: how to use the upper() - buran - Sep-26-2017 (Sep-26-2017, 10:34 AM)Saka Wrote: Here's a little "function pack" for you: stringhere.find(), this function can find substrings in strings String slicing with [:] String manipulation via lists while this would probably yield the desired result, it is definitely not among the best approaches to solve the task. just a kind remark |