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

BF: Replaced variable from previous loop with the one from the printing loop #11

Open
wants to merge 2 commits into
base: pbs-psyc161-wi19
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions _sources/Classes/sorting_instances.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ Sometimes you will find it convenient to define a method for the class that does
return self.price

L = [Fruit("Cherry", 10), Fruit("Apple", 5), Fruit("Blueberry", 20)]
print "-----sorted by price, referencing a class method-----"
print("-----sorted by price, referencing a class method-----")
for f in sorted(L, key=Fruit.sort_priority):
print(f.name)

print "---- one more way to do the same thing-----"
print("---- one more way to do the same thing-----")
for f in sorted(L, key=lambda x: x.sort_priority()):
print(f.name)

2 changes: 1 addition & 1 deletion _sources/Sorting/SortingaDictionary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Here's a version of that using a named function.

# now loop through the keys
for k in y:
print("{} appears {} times".format(x, d[x]))
print("{} appears {} times".format(k, d[k]))

.. note::

Expand Down