+ 3
I tried to solve the following problem. However, it is returning invalid syntax in line 5. Also I could not solve it.
Your friend sent you a message, however his keyboard is broken and types a # instead of a space. Replace all of the # characters with spaces and output the result. txt = input() #your code goes here for i in txt: if (txt[i]==#): txt=txt.replace(txt[i], " " ) print(txt)
14 Antworten
+ 5
correct code
txt = input()
b = txt.replace('#',' ')
print(b)
+ 4
txt = input()
#your code goes here
print (txt .replace("#", " "))
+ 4
I solved this with the following:
msg = input()
print (msg.replace("#", " "))
This way the print function is integrated with the replace so no need for a separate line to print.
+ 3
txt = txt.replace("#", " ")
- - - - - - - - - - - - -
You dont actually need to iterate all the elements cause the iteration is already happening behind or in the background when you use "replace"
This read as:
replace "#" with " "
+ 1
Here is how I solved it:
text = input()
print(text.lower())
0
Thank you so much. It was much easier than I thought for 2 hours.
0
I solved it this way:
x = msg.replace("#", " ")
print(x)
0
x = input()
txt = x.lower()
print(txt)
0
txt = input()
print(txt.replace("#", " "))
0
txt = input()
txt = txt.replace('#',' ')
print(txt)
done..!
0
txt = input()
txt = txt.replace('#',' ')
print(txt)
0
msg = input()
msg = msg.replace('#', ' ')
print(msg)
0
txt = input()
#your code goes here
txt= (txt.replace("#"," "))
print(txt)
- 1
txt = input()
#your code goes here
print(txt.replace("#"," "))