Python Forum
Please review and help me on this code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please review and help me on this code
#1
Money Bank operates several branches in a city. Each bank branch offers financial services. The branch manager of the bank wants to know the most visited service counter in a day. The details of the financial services are stored in a dictionary as follows:
{ "L" : "Loans", "C" : "Credit Cards", "M" : "Mutual Funds", "I" : "Insurance" }
The customer id of the customer along with the service counter visited by the customer is stored in a list as given below:
[409,’L’,505,’L’,304,’M’,209,’I’] 
Problem:
Write a python function most_visited_service (). The function will find the financial service visited by the maximum number
of customers and return the name of the service. If the maximum number of customers is equal for more than one service,
return the list of all respective services. If the input has a service which is not mentioned in the dictionary,
perform error handling then print “Service not found”

Test your code by using the sample inputs given below:
Output:
Sample Input Expected Output [409,’L’,505,’L’,304,’M’,209,’I’,809,’I’,409,’L’] Loans [409,’L’,505,’L’,304,’M’,209,’I’,409,’M’] [“Loans”, “Mutual Funds”] [202,’L’,407,’X’,809,’I’,409,’L’] Service not found
Solution:

Bank_Services = {
"L" : "Loans",
"C" : "Credit Cards",
"M" : "Mutual Funds",
"I" : "Insurance"
}
print(Bank_Services)

print(Bank_Services['L'])
print(Bank_Services['C'])
print(Bank_Services['M'])
print(Bank_Services['I'])

Cust_List =[409,'L',505,'L',304,'M',209,'I'] 
print(Cust_List)

Cust_ID =[409,505,304,209,809,202,407]
print(Cust_ID)
Can some one please help me how to write the next code

Thanks
Sushma
Yoriz write Aug-04-2021, 07:21 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
Please use the Button Insert python and insert your code.
Reply
#3
Is everything on buffer ? I recommend to use pickle or redis for storing visiting customer data or any database . Is it possible or not ?
Reply
#4
https://python-forum.io/misc.php?action=help&hid=52 Wrote:This forum is focused on education. It exists to help people learn Python. We don’t exist to solve others’ problems, although that tends to be a happy byproduct of education
buran likes this post
Reply
#5
Hello,

I think the easiest way to do it (whereby you can understand it easily) is to have a variable counter for each type (L,M,I...) and then have another line of code check through the arrays in increments.

For example:
i = 0
while True:
     if array[i] <= array.len():
              number_of_m += 1
              i += 2
     elif:
         break
This code won't work for your example but the logic and syntaxes of this is something you can look into. You could after this compare the results and spit out a result using the print function. If you want a bit more information then drop me a private message on here.

I would use this as a starting point but it can get messy and so generally you should be staying away from having lots of extra variables.

Kind regards,
James
while dad_has_cigs == True:
    happiness = True
    if dad_has_cigs == False:
    print("Dad come home!")
    happiness = not happiness
    break
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Code Review and Challenge cpatte7372 2 1,984 Jan-14-2022, 10:45 AM
Last Post: cpatte7372
  Requesting homework help and maybe a little code review… JonnyEnglish 0 1,594 Jan-16-2020, 04:34 PM
Last Post: JonnyEnglish
  Code Review: Range and Enumerate lummers 2 2,109 Jan-11-2020, 12:40 AM
Last Post: lummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020