From the course: Python Quick Start
Unlock this course with a free trial
Join today to access over 24,500 courses taught by industry experts.
Defining iteration - Python Tutorial
From the course: Python Quick Start
Defining iteration
Let's say two people, Player 1 and Player 2 are playing guess the word. Player 1 comes up with a word or phrase and Player 2 needs to guess it. During the game, Player 1 can provide hints to Player 2 so Player 2 can make more informed guesses. One of these hints might be the number of vowels in the word or phrase. As a fun exercise, let's say you're going to code guess the word, meaning you're building the game so it can be played online. Given the correct word or phrase, how exactly would you find the number of vowels in it? You do this by going through each character in the correct word or phrase, checking if that character is a vowel and keeping track of how many vowels you encounter. The word that Player 1 comes up with can be stored in a variable named word. Say Player 1 chooses "serendipitous." So you could create a variable named word and assign it to the string, "serendipitous." So word has the value of serendipitous. Now, you probably know what vowels are, but your computer…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.