""" Write a program that reads the string and replaces '*' with 'a'. Pay attention: you need to create a new string. """ def replace_char(str, old_char, new_char): #replaces old_char with new_char and returns a new string #you cannot change the string #you have to create a new string new_str="" for item in str: if(item==old_char): new_str+=new_char else: new_str+=item return new_str def main(): #solution 1 print('solution 1') str=input("enter string ") new_str="" size=len(str) for i in range(size): if(str[i]=='*'): new_str=new_str+'a' else: new_str=new_str+str[i] print("new string",new_str) #solution 2 print('solution 2') str=input("enter string ") new_str="" for item in str: if(item=='*'): new_str=new_str+'a' else: new_str=new_str+item print("new string",new_str) #solution 3 print('solution 3') str=input("enter string ") print("new string",replace_char(str,'*','a')) main()