[Python] Removing brackets, round brackets parenthesis and commas

Discussão em 'Python' iniciado por Stack, Março 15, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to make a fun party game for my friends and I to play but the code is leaving brackets and other stuff on my statements. I want it to look like this: "Gerald was killed with a frying pan" not ('Gerald',) was killed with a frying pan.

    #here is my code
    people = ["the boogie man"]
    while True:
    item = input("Enter a person (or 'q' to quit): ")
    if item.lower() == 'q':
    break
    people.append(item)
    print(people)
    import random
    person = (*random.sample(people, k=1),)
    #trying to get rid of the extra stuff
    person1 = (*random.sample(people, k=1),)
    person2 = (*random.sample(people, k=1),)
    person3 = (*random.sample(people, k=1),)

    Locations = ["the lagoon", "the basement", "the dark forest", "the kitchen", "the backyard", "the batcave"]
    weights = [1, 1, 1, 1, 1, 1]
    location = random.choices(Locations, weights=weights, k=1)[0]

    Weapons = ["flintlock pistol", "shotgun", "AK-47", "steak knife", "butter knife", "fork", "infant child", "batman"]
    weights = [1, 1, 1, 1, 1, 1, 1, 1]
    weapon = random.choices(Weapons, weights=weights, k=1)[0]

    cod = ["poisioned bagels", "a seigure", "a todler with a plastic spoon", "slippery floor sign not being on the slippery floor"]
    weights = [1, 1, 1, 1]
    causeofdeath = random.choices(cod, weights=weights, k=1)[0]

    messages = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]
    weights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
    message = random.choices(messages, weights=weights, k=1)[0]
    if message == "1":
    print(str(person) + " killed " + str(person1) + " with a " + weapon + " and hid the body in " + location)
    if message == "2":
    print(str(person) + " saved " + str(person1) + " from " + str(person2) + " who was trying to kill them using a " + weapon)
    if message == "3":
    print(str(person) + " swears they are innocent")
    if message == "4":
    print(str(person) + " paid " + str(person1) + " to kill " + str(person2) + " with a " + weapon)
    if message == "5":
    print(str(person) + " framed " + str(person1) + " for " + str(person2) + "'s murder")

    Continue reading...

Compartilhe esta Página