Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another reason why for loops are useful #525

Open
leavesntwigs opened this issue May 14, 2018 · 0 comments
Open

Another reason why for loops are useful #525

leavesntwigs opened this issue May 14, 2018 · 0 comments

Comments

@leavesntwigs
Copy link

In the section about for loops ...
"One way to print each character is to use four print statements:
print(word[0])
print(word[1])
print(word[2])
print(word[3])

...
This is a bad approach for two reasons:"

Another reason why this is a bad approach is for maintenance. If we wanted to print each letter followed by a comma, for example, we would have to change four lines of code. If we have a for loop, with a single print(word[I]) then we need only change one line of code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant