Talk Like a Pirate

pirate.py: 8 points


The goal of this part of the lab is to give you experience manipulating and altering strings. In order to do this, you will write a program that prompts the user for a string and prints out a pirate-speak version of the string. To create your pirate-speak version, you should change any occurrence of the letter “r” into “rrr” (i.e., the letter r repeated three times). Some example runs of the program are below.

Please enter a String to be pirated: agar agar
Arrr, matey, your String be: agarrr agarrr
Please enter a String to be pirated: arrr
Arrr, matey, your String be: arrrrrrrrr
Please enter a String to be pirated: hello
Arrr, matey, your String be: hello
Please enter a String to be pirated: I'm disinclined to acquiesce to your request
Arrr, matey, your String be: I'm disinclined to acquiesce to yourrr rrrequest

For details on how to loop over and manipulate strings, please see the Warmup.

ReadMe

Be sure to include a main() function in all of your programs moving forward! You’ll see the following command in all your starter files for this lab:

if __name__ == '__main__':
  main()

This means that Python will run main() when you run the file in the Shell (e.g., python pirate.py).