Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Daniel Awerbuck
- # ITP115, Fall 2019
- # Lab 4
- # dawerbuc@usc.edu
- import random
- def function(word):
- translatedString = word[1:] + word[0]
- translatedString = translatedString.replace('k','c')
- if len(word) >= 4:
- translatedString = translatedString + getRandomVowel() + getRandomVowel() #add two vowels if word over 3 letters
- elif len(word) <= 3: #add en if word less than 4 letters
- translatedString += "en"
- elif translatedString[-1] == "e":
- translatedString = translatedString[:len(translatedString) - 1] + "ë" #replace last letter e with ë
- if translatedString[0].upper() == True:
- translatedString == translatedString.lower()
- translatedString[0] == translatedString[0].upper()
- return translatedString
- def getRandomVowel(): #function returns a random vowel from the list aeiou, easy to implement into the translate function
- vowellist = "aeiou"
- vowels = random.randint(0, 4) #
- return vowellist[vowels]
- print("Elcómewó óten heten Igpén Lvísheá ránslátórtë!\n(Welcome to the Pig Elvish translator!)")
- continueProgram = True
- while continueProgram:
- ogword = input("Please enter a word to translate: ")
- translated = function(ogword)
- print("'" + ogword + "' in elvish is: " + translated)
- cont = input("Would you like to enter another word?(y/n): ")
- if cont.lower() == "n":
- continueProgram = False
- print("Oodbyega! Aveha aen icenë ayden!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement