Python Forum
Solving a problem need help!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solving a problem need help!
#1
Hi guys I would love to get some help on the following problem. :)

List Manipulator
Our player is having trouble with his friend list and some guys are disappearing without a reason so he asks you to create a program that will figure out what is going on and at the end will bring him a report.
On the first line you will receive all his friends separated by ", ". On the next lines until the "Report" command you will receive commands. The commands could be:
• Blacklist {name}
• Find the name in the friend list and change it to "Blacklisted" and print on the console:
• "{name} was blacklisted."
• If the name is not in the friend list print:
• "{name} was not found."
• Error {index}
• Check if the username at the given index is not "Blacklisted" or "Lost". If it isn't, change the username to "Lost" and print on the console:
• "{name} was lost due to an error."
• Change {index} {newName}
• Check if the user at index position is in range of the array. If he is, change the current username with the new one and print on console:
• "{currentName} changed his username to {newName}."
After you receive "Report" print on the console the count of blacklisted names, the count of lost names, and the friend list separated by a single space.
Input
• The first input line will contain the usernames that need to be stored.
• On the next input lines until "Report" you will receive commands.
Output
• The output should be in the following format:
• "Blacklisted names: {blacklistedNamesCount}"
• "Lost names: {lostNamesCount}"
• "{name1} {name2} .. {nameN}"
Reply
#2
Please, don't create multiple threads.
We are glad to hello, but you need to show some effort. Post the code you have so far, if you get error - post the full traceback. Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Nov-07-2020, 06:21 PM)buran Wrote: Please, don't create multiple threads.
We are glad to hello, but you need to show some effort. Post the code you have so far, if you get error - post the full traceback. Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.
https://pastebin.com/q8GeUj7x

friend_names = input().split(", ")
command = input().split()
lost_names = 0
def in_blacklist(blacklist, names_is):
    return True if names_is in blacklist else False
def in_friendlist(friendlist, name_is1):
    return True if name_is1 in friendlist else False
 
while not command == "Report":
    command_type = command[0]
    name = command[1]
 
    if command_type == "Blacklist":
        while not command[1]=="":
            if in_blacklist(friend_names,name):
                print(f"{name} was blacklisted")
            elif not in_friendlist(friend_names, name):
                print(f"{name} was not found.")
 
    if command_type == "Error":
        if name is not in_blacklist(friend_names,name):
            print(f"{name} was lost due to an error.")
    if command_type == "Change":
        index = friend_names[0]
        if index = 
That is what I have so far :)
Not sure if it is correct in any way shape or form. Just tried to do something but can't solve the problem
buran write Nov-07-2020, 06:36 PM:
I have added your code here, in python tags. we prefer to have the code here, not on external site. Of course if it's too big, a lot of files, etc. it should be in a repo. Generally, you should make minimal reproducible example.
Reply
#4
Your last line is not complete.
Apart from that - what problem have you identified? Did you get error. Does it do something that you not expect? Be more specific...
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
(Nov-07-2020, 06:28 PM)totoandreev Wrote:
(Nov-07-2020, 06:21 PM)buran Wrote: Please, don't create multiple threads.
We are glad to hello, but you need to show some effort. Post the code you have so far, if you get error - post the full traceback. Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.
https://pastebin.com/q8GeUj7x

friend_names = input().split(", ")
command = input().split()
lost_names = 0
def in_blacklist(blacklist, names_is):
    return True if names_is in blacklist else False
def in_friendlist(friendlist, name_is1):
    return True if name_is1 in friendlist else False
 
while not command == "Report":
    command_type = command[0]
    name = command[1]
 
    if command_type == "Blacklist":
        while not command[1]=="":
            if in_blacklist(friend_names,name):
                print(f"{name} was blacklisted")
            elif not in_friendlist(friend_names, name):
                print(f"{name} was not found.")
 
    if command_type == "Error":
        if name is not in_blacklist(friend_names,name):
            print(f"{name} was lost due to an error.")
    if command_type == "Change":
        index = friend_names[0]
        if index = 
That is what I have so far :)
Not sure if it is correct in any way shape or form. Just tried to do something but can't solve the problem

I just don't know how to continue solving it. It is a problem that I can't solve myself that's why I wanted to ask for someone's help. So they can solve it and I can look at the solution and understand it.
Reply
#6
(Nov-07-2020, 06:41 PM)buran Wrote: Your last line is not complete.
Apart from that - what problem have you identified? Did you get error. Does it do something that you not expect? Be more specific...

Just don't know how to solve it. I can't do it on my own.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help solving Python problem WHelped 4 3,463 Apr-17-2018, 06:36 AM
Last Post: WHelped

Forum Jump:

User Panel Messages

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