CS 111: Introduction to Computer Science

Playing with strings

Hand in as: stringmenu/stringmenu.py

The program

As Chapter 4 of your textbook illustrates in some detail, Python provides you with lots of ways of manipulating character strings. In this assignment, you will write a small menu-driven program that will enable your user to experiment with some of Python's string methods.

When a person executes your program, your program should ask the person to enter a string. Next, the following menu should appear:

A. Capitalize all letters in the string. B. How many characters are in the string? C. Strip the white space from the beginning and end of the string. D. Does the string contain the substring "goat"? E. How many times does the letter "e" appear in the string? Your choice?

Once the person makes a choice, the program should perform the requested task.

To get started, save and run this program: menu.py. This program illustrates a simple menu-and-response structure that you can adapt for this assignment.

Notes on handing in your code

Start early, have fun, and keep in touch.