Skip to content

Commit a31d2b1

Browse files
practicing python
1 parent 9c9d9bd commit a31d2b1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# input is a list of integer pairs
2+
# in each pair in the list,
3+
# first number: number of ppl that get on the bus
4+
# second number: number of people that get off the bus
5+
# all numbers are positive.
6+
7+
# declare variable count
8+
# iterate over list
9+
# first number of element is always added to count
10+
# second number is always subtracted from count
11+
#
12+
13+
def number(bus_stops):
14+
# count = 0
15+
# for stop in bus_stops:
16+
# count += stop[0]
17+
# count-= stop[1]
18+
19+
# return count
20+
return sum([stop[0] - stop[1] for stop in bus_stops])
21+
22+
print(number([[10,0],[3,5],[5,8]]),5)

0 commit comments

Comments
 (0)