Open In App

UwU text convertor in Python

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

UwU is used as an emoticon to demonstrate a reaction to something cute. In this emoticon, the ‘U’s signify 2 closed eyes and the ‘w’ signifies the clenched, excited mouth lips. Imagine seeing something cute, like a baby cutely sneezing, the response can be UwU which is pronounced as “ooh-wooh”.

UwU text is the type of lingo in which the original text has been “UwUfied”. UwU text is supposed to be a cuter version of the original text. It is popular with certain online communities, mostly as a fun practice.

Examples: 

Input :  The quick brown fox jumps over the lazy dog.
Output : The quick bwown fox jumps ovew the wazy dog.

Input : Nooo! I was not late to work!
Output : Nyooo! I was nyot wate to wowk!

Algorithm :  

  • Change all the ‘R’s and ‘r’s to ‘w’ and ‘W’ respectively.
  • Change all the ‘L’s and ‘l’s to ‘w’ and ‘W’ respectively.
  • If the current character is ‘o’ or ‘O’ and the previous character is either ‘M’, ‘m’, ‘N’ or ‘n’, then add ‘y’ between the characters.
  • If none of the condition matches for any character then leave that character as it is.

Python3




# Function to convert into UwU text
def generateUwU(input_text):
     
    # the length of the input text
    length = len(input_text)
     
    # variable declaration for the output text
    output_text = ''
     
    # check the cases for every individual character
    for i in range(length):
         
        # initialize the variables
        current_char = input_text[i]
        previous_char = '&# 092;&# 048;'
         
        # assign the value of previous_char
        if i > 0:
            previous_char = input_text[i - 1]
         
        # change 'L' and 'R' to 'W'
        if current_char == 'L' or current_char == 'R':
            output_text += 'W'
         
        # change 'l' and 'r' to 'w'
        elif current_char == 'l' or current_char == 'r':
            output_text += 'w'
         
        # if the current character is 'o' or 'O'
        # also check the previous character
        elif current_char == 'O' or current_char == 'o':
            if previous_char == 'N' or previous_char == 'n' or previous_char == 'M' or previous_char == 'm':
                output_text += "yo"
            else:
                output_text += current_char
         
        # if no case match, write it as it is
        else:
            output_text += current_char
 
    return output_text
     
# Driver code
if __name__=='__main__':
    input_text1 = "The quick brown fox jumps over the lazy dog."
    input_text2 = "Nooo ! I was not late to work !"
    print(generateUwU(input_text1))
    print(generateUwU(input_text2))


Output : 

The quick bwown fox jumps ovew the wazy dog.
Nyooo! I was nyot wate to wowk!

 



Last Updated : 07 Aug, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads