Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

(singke) #1

... print (list_of_names)
... break
... list_of_names += the_name
...
Enter name: Raz
Enter name: Berry
Enter name: Pi
Enter name:
RazBerryPi








Try It Yourself: Use a while Loop to Enter Data
A loop is a useful tool for entering data. In the following steps, you will be creating a
script to enter a fictitious club’s member list by using a while loop. The script will
ask up front for the number of member names you will be entering, and then the while
loop will ask for the member’s first, middle, and last names. Follow these steps:


  1. If you have not already done so, power up your Raspberry Pi and log in to the
    system.

  2. If you do not have the LXDE GUI started automatically at boot, start it now by typing
    startx and pressing Enter.

  3. Open the IDLE window by double-clicking the IDLE 3 icon.

  4. Open the IDLE text editor window by pressing Ctrl+N.

  5. Type the code shown in Figure 7.4 into the IDLE text editor window, pressing Enter
    when you need to get to the next line.


FIGURE 7.4 The script0702.py script.

By the Way: Be Careful!
Be sure to take your time here and avoid making typographical errors. You can
make corrections by using the Delete key and the up- and down-arrow keys.
Free download pdf