This is what my code currently looks like. I wanted to change the emoticons to emojis when the user inputs a sentence or word. How do I go by it?
def main():
sentence = input("Input a Sentence: ")
convert(sentence)
print(sentence)
def convert():
emo1 = ":)"
emo2 = ":("
emo1.replace(":)", "🙂")
emo2.replace(":(", "🙁")
main()
You need to add replace emoticons in sentence you sent to function convert
.
def main():
sentence = input("Input a Sentence: ")
print(sentence)
sentence = convert(sentence)
print(sentence)
def convert(sentence):
sentence = sentence.replace(":)", "🙂")
sentence = sentence.replace(":(", "🙁")
return sentence
main()
def main(): # user input
variable_faces = input("Enter your sentence or word: ")
print(change_faces(variable_faces))
def change_faces(sentence): sentence = sentence.replace(":)", "🙂") sentence = sentence.replace(":(", "🙁")
return sentence
main()
#Worked like a charm
def main():
x = input('Type: ')
print(convert(x))
def convert(x):
x=x.replace(':)', '🙂')
x=x.replace(':(', '🙁')
return x
main()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.