Python Forum
The LOL Translator - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: Code sharing (https://python-forum.io/forum-5.html)
+--- Thread: The LOL Translator (/thread-2823.html)



The LOL Translator - SpeedyZapGaming - Apr-12-2017

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.


RE: The LOL Translator - teenspirit - Apr-13-2017

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


RE: The LOL Translator - SpeedyZapGaming - Apr-13-2017

(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


RE: The LOL Translator - buran - Apr-13-2017

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.


RE: The LOL Translator - SpeedyZapGaming - Apr-13-2017

Thanks man! :D

I did this when I was a beginner so... :|


RE: The LOL Translator - zivoni - Apr-13-2017

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 ...


RE: The LOL Translator - SpeedyZapGaming - Apr-13-2017

Thanks bro! :D


RE: The LOL Translator - GamingAgent - Apr-15-2017

Hi! Awesome project you made!