From 79ca50ba0579a91c7088442fda476c7106bb607a Mon Sep 17 00:00:00 2001 From: Helen Liu Date: Tue, 24 Jan 2023 17:49:53 -0600 Subject: [PATCH] in class exercise solution --- Student_Names.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Student_Names.py b/Student_Names.py index c6bf448..12a32ee 100644 --- a/Student_Names.py +++ b/Student_Names.py @@ -1,8 +1,10 @@ -s = open('studentnames.txt', 'r') -print(s.readline().rstrip('\n')) -print(s.readline().rstrip('\n')) -print(s.readline().rstrip('\n')) -print(s.readline().rstrip('\n')) -print(s.readline().rstrip('\n')) -print(s.readline().rstrip('\n')) +s = open('StudentNames.txt', 'r') +tmp=s.readline().rstrip('\n') +print(tmp) +count=1 +while(tmp!=""): + tmp=s.readline().rstrip('\n') + print(tmp) + count+=1 +print(count) s.close() \ No newline at end of file