0

Python function

Write a Python program to read the data as described above and print out details about books that have been checked out. Each line should describe to one currently issued book in the following format: Due Date~Full Name~Accession Number~Title Your output should be sorted in increasing order of due date. For books due on the same date, sort in increasing order of full name. Here is a sample input and its corresponding output. Sample Input Books APM-001~Advanced Potion-Making GWG-001~Gadding With Ghouls APM-002~Advanced Potion-Making DMT-001~Defensive Magical Theory DMT-003~Defensive Magical Theory GWG-002~Gadding With Ghouls DMT-002~Defensive Magical Theory Borrowers SLY2301~Hannah Abbott SLY2302~Euan Abercrombie SLY2303~Stewart Ackerley SLY2304~Bertram Aubrey SLY2305~Avery SLY2306~Malcolm Baddock SLY2307~Marcus Belby SLY2308~Katie Bell SLY2309~Sirius Orion Black Checkouts SLY2304~DMT-002~2019-03-27 SLY2301~GWG-001~2019-03-27 SLY2308~APM-002~2019-03-14 SLY2303~DMT-001~2019-04-03 SLY2301~GWG-002~2019-04-04

1st Mar 2019, 9:42 AM
Roshini Manoharan
5 odpowiedzi
+ 1
https://code.sololearn.com/cz0LMBzX71tO/?ref=app Please help!!! I tried a lot... It's not working
3rd Mar 2019, 3:54 AM
Roshini Manoharan
0
Please show us your attempt.
1st Mar 2019, 12:26 PM
Diego
Diego - avatar
0
That's my attempt 😪 Diego
2nd Mar 2019, 10:57 AM
Roshini Manoharan
0
Looks like your comment (the one with the code) reached maximum characters allowed and isn't complete. Try pasting it on the Playground and then share the link to it.
2nd Mar 2019, 12:20 PM
Diego
Diego - avatar
- 1
# function to take the input of the string def stu_input(l): x=input() while x!='books': x=x.split('~') x.append(0) # appending 0 as the books marks l.append(x) x=input() # function to take the books of the students def inp_books(books): x=input() while x!='EndOfInput': x=x.split('~') x=x[len(x)-2:] books.append(x) x=input() def com(x): if x=='A': return 10 elif x=='AB': return 9 elif x=='B': return 8 elif x=='BC': return 7 elif x=='C': return 6 elif x=='CD': return 5 else: return 4 def cal(): global li,books for i in li: # i is a list containg the name and roll of a student j=0 sum=0 while j<len(books): if i[0]==books[j][0] : # if the roll matchs sum=sum+com(books[j][1]) books.pop(j) i[2]+=1 else : j+=1 if sum!=0
2nd Mar 2019, 10:54 AM
Roshini Manoharan