Wednesday, 13 June 2018

To get a string from a given string where all occurrences of its first char have been changed to '$', except the first char itself.

# To get a string from a given string where all occurrences of its first char have
# been changed to '$', except the first char itself.

str = input("Enter a String : ")

if len(str)>0:
    fChar = str[0]
    str = str.replace(fChar,"$")
    str = fChar + str[1:]
    print(str)
else:
    print("String is empty.")

input("Press Enter to exit.")

No comments:

Post a Comment

Featured post

In all other cases the driver is not insured. If the marital status, sex and age of the driver are the inputs, write a program to determine whether the driver is to be insured or not.

  #include #include int main() { char ms;   printf("Is Driver married (Y/N): ");  scanf("%c",&ms);   if(ms=='y&#...

Popular Posts