Python Forum
Thread Rating:
  • 3 Vote(s) - 3.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The LOL Translator
#1
Hello everyone I'm an average python coder so I just coded a LOL Translator. Just wanted to ask for suggestions on how to improve it!
""" This is the lol-translator by: SpeedyZapGaming """

# Variable
lollish = "ololly"

# Intro
print ("Hello and welcome to the lol-translator!")
print ("This translator was made for fun by SpeedyZapGaming.")
print ("If you are gonna re-upload this then please give credit.")
print ("This translator does NOT accept numbers.")
print("You are allowed to use any language.")

# Asks for word
Word = input("What is the word you want us to translate?: ")

# Result
if len (Word) > 0 and Word.isalpha():
    TheWord = Word.lower()
    FirstLetter = TheWord[0]
    if FirstLetter == "a" or FirstLetter == "e" or FirstLetter == "i" or FirstLetter == "o" or FirstLetter == "u":
        NewWord = Word.lower() + lollish
        print ("The result is,", NewWord)
        print ("Thank you for using the lol translator by SpeedyZapGaming. See you soon!")
    else:
        NewWord = TheWord[1:] + FirstLetter + lollish
        print("The result is,", NewWord)
        print ("Thank you for using the lol translator by SpeedyZapGaming. See you soon!")
else:
    print ("You have typed in nothing.")
    print ("OR... You typed in numbers.")
    print ("Please restart the translator")
Thank you for the Feedback!

And also, please type in the code I should edit, add or delete.  Think 
Thanks.
Reply
#2
Turn your program into a function. Then you can add more features or options in the future without having to rewrite any code and can adjust where your current code runs.

Also, I recommend the SPYDER python ide, it is the best i have used so far, and it is free
Reply
#3
(Apr-13-2017, 02:19 AM)teenspirit Wrote: Turn your program into a function. Then you can add more features or options in the future without having to rewrite any code and can adjust where your current code runs.
Also, I recommend the SPYDER python ide, it is the best i have used so far, and it is free
Thanks for the Feedback! :D
Reply
#4
1. This
if len (Word) > 0 and Word.isalpha():
is same as
if Word.isalpha():
2. on line 21 - use TheWord - it's already lowercase
NewWord = TheWord + lollish
3. instead printing result twice - on lines 22 and 23 and on lines 25 and 26, do it just once - after the if/else

4. Read and adhere to PEP8, e.g. naming conventions for names (i.e. variables) - first_letter, instead of FirstLetter, new_word instead of NewWord, etc. , constants - e.g. eventually use LOLLISH, instead of lolish, because it's not going to change and is sort of constant.
Reply
#5
Thanks man! :D

I did this when I was a beginner so... :|
Reply
#6
if FirstLetter == "a" or FirstLetter == "e" or FirstLetter == "i" or FirstLetter == "o" or FirstLetter == "u":
is same as
if FirstLetter in ['a', 'e', 'i', 'o', 'u']:
And you know that FirstLetter is a single character, so it is same as
if FirstLetter in "aeiou":
Its questionable which of last two versions is more readable ...
Reply
#7
Thanks bro! :D
Reply
#8
Hi! Awesome project you made!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple Binary Translator (Using MATH instead of MATCH)) DataCorrupt 3 2,627 Jun-09-2020, 06:26 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020