Skip to content

Commit d7aa18e

Browse files
part 6.1 added
1 parent acbd4b5 commit d7aa18e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# The file numbers.txt contains integer numbers, one number per line.
2+
# The contents could look like this:
3+
4+
# 2
5+
# 45
6+
# 108
7+
# 3
8+
# -10
9+
# 1100
10+
# ...etc...
11+
12+
# Please write a function named largest, which reads the file and returns the largest number in the file.
13+
14+
# Notice that the function does not take any arguments. The file you are working with is always named numbers.txt.
15+
16+
# NB: If Visual Studio Code can't find the file and you have checked that there are no spelling errors, take a look at the instructions following this exercise.
17+
18+
def largest():
19+
with open("numbers.txt") as new_file:
20+
counter = 0
21+
22+
for line in new_file:
23+
line = int(line.replace("\n", ""))
24+
if line > counter:
25+
counter = line
26+
return counter

0 commit comments

Comments
 (0)