Question: Write a function before _ a ( word ) that takes in a string representing a single lowercase English word, and returns the same word

Write a function before_a(word) that takes in a string representing a single lowercase English word, and returns the same word but with all letters that come before the first 'a' moved to the end of the string (NOT including the 'a' itself). Only the location of the first 'a' matters. You can assume there will be at least one 'a'.
Submit your code to Gradescope in a file called ex8-2.py.
Examples:
if __name__=='__main__':
print(before_a('trains')) #ainstr
print(before_a('attractor')) #attractor
print(before_a('chronophobia')) #achronophobi

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!