- #1
late347
- 301
- 15
#mark contains personal comments and thoughts
# BTW this assignment was a beginner exercise at codeacademy intended to test the usage of if-structures
# I was wondering about whether or not if-structure was going to work, or if I needed a loop-structure becauses I wanted to interrogate the input, whether or not it passes the criteria (not contains numbers).
And only in such cases where the criteria is passed then you would execute program for translating. Otherwise keep asking for input until it is correctly written into the program.
""" requirements of the code are shown in, as they are described below"""
# BTW this assignment was a beginner exercise at codeacademy intended to test the usage of if-structures
# I was wondering about whether or not if-structure was going to work, or if I needed a loop-structure becauses I wanted to interrogate the input, whether or not it passes the criteria (not contains numbers).
And only in such cases where the criteria is passed then you would execute program for translating. Otherwise keep asking for input until it is correctly written into the program.
""" requirements of the code are shown in, as they are described below"""
- ask for input, which must be not be allowed to be numbers. Neither reals nor integers allowed in the input word.
- interrogate whether or not the input word is letters only. Essentially it would also be good if only the standard letters a-z can be contained in input.
- the printout answer must be the letters of the input word rearranged as follows:
- the last two letters of the printout are always "ay"
- the first letter of the input word is moved into immediately in front of the "ay" at the printout stage
- the printout begins with the second letter of the input word
- printout must be in lowercase
- printout must be one-mashed-together-word -no empty spaces allowed etc...
Python:
answer = input("which word can I translate into pyg latin btw give only letters")
while str.isalpha(answer) == False: # I had to google this function str.isalpha()
answer = input(" tell me only letters so we can begin")
# in the cases when str.isalpha() gives False, then you are stuck in loop as you should be
# in the case of True, then you proceed as below into printout stage, out of the loop I think this is what goes on
lowerAnswer = answer.lower()
start=lowerAnswer[1 : len(lowerAnswer)]
mid=lowerAnswer[0]
finish="ay"
print("\n{}{}{}".format(start, mid,finish)) #it was quite difficult to get this string printout properly done also in python 3
Last edited by a moderator: