- 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;

2nd Aug 2022, 5:08 PM
ADYA RAI
ADYA RAI - avatar
9 ответов
+ 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⭐
2nd Aug 2022, 5:34 PM
Lisa
Lisa - avatar
+ 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
2nd Aug 2022, 8:25 PM
Lothar
Lothar - avatar
+ 4
ADYA RAI just for your understanding and since you coded nothing up to know. SOLOLEARN is no homework delivery!
4th Aug 2022, 9:26 AM
Oma Falk
Oma Falk - avatar
+ 2
Your task description seems incomplete to me. Please give an example and link your code attempt. Please tag "Python".
2nd Aug 2022, 5:24 PM
Lisa
Lisa - avatar
+ 1
Why not '$esta$t'? And how is determined which character will be replaced? Please give all relevant inputs
2nd Aug 2022, 5:28 PM
Lisa
Lisa - avatar
+ 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.
4th Aug 2022, 8:53 AM
Oma Falk
Oma Falk - avatar
0
Example = 'restart' Expected = 'resta$t'
2nd Aug 2022, 5:25 PM
ADYA RAI
ADYA RAI - avatar
0
The repeated occurrence of first char has to be replaced
2nd Aug 2022, 5:30 PM
ADYA RAI
ADYA RAI - avatar
0
OK
4th Aug 2022, 9:06 AM
ADYA RAI
ADYA RAI - avatar