- 1
Write a Python program to get a string from a given string where all occurrences of its first char have been changed to '#x27;
9 Respostas
+ 5
Okay, and what if there are multiple occurrences of more than one character? Will the subsequent character be replaced as well?
You could approach the task like this:
* Identify all characters that occur more then once.
* Find the indices of these characters
* Replace the characters at all but their lowest found index.
If you need help with code, please ⭐LINK YOUR CODE ATTEMPT⭐
+ 5
ADYA RAI ,
may be this helps:
in case all duplicates of the first character should be replaced, by keeping the first character:
assuming the string consist only of one word
- make a copy of the first character
- replace all duplicates in string but start from index 1 not from 0
- concatenate the first character + the result from the replace operation
- print the result
+ 4
ADYA RAI just for your understanding and since you coded nothing up to know.
SOLOLEARN is no homework delivery!
+ 2
Your task description seems incomplete to me. Please give an example and link your code attempt.
Please tag "Python".
+ 1
Why not '$esta$t'? And how is determined which character will be replaced? Please give all relevant inputs
+ 1
Apply regex.sub on the tail of the word, where the head of the word is to be substituted. Add substituted tail to head.
0
Example = 'restart'
Expected = 'resta$t'
0
The repeated occurrence of first char has to be replaced
0
OK