-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpigLatin.py
More file actions
30 lines (21 loc) · 929 Bytes
/
pigLatin.py
File metadata and controls
30 lines (21 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# pig latin translator
print('Welcome to the Pig Latin Translator!')
#create a variable to hold our translation suffix.
pyg = 'ay'
original = input('Enter a word: ')
# checking if the user enetered some words
if len(original) and original.isalpha() > 0:
# isalpha checks if only alphabetical characters were enetered by the user
# test multiple inputs ( empty, numeric etc) to test the code
#print(original)
word = original.lower()
first = word[0]
#print(first)
# Now that we have the first letter stored, we need to add both the letter and the string stored in pyg to the end of the
# original string.
new_word = word[1:len(word)] + first + pyg
print(new_word)
# this is similar to new_word=[1:]
else:
print('empty')
# Besides isalpha(), check other built-in methods such as: isdigit() for digits, isnumeric() for numbers or isdecimal() for decimal characters