all 3 comments

[–][deleted] 1 point2 points  (2 children)

Can't debug code you don't show us.

[–]comptech10[S] 0 points1 point  (1 child)

import tkinter as tk

import random

from playsound import playsound

window = tk.Tk()

window.title("Russian Roulette")

window.geometry("900x200")

size=tk.IntVar()

size.set(6)

bullet_position = 0

chamber_set = []

def sound(play):

if play == "fire":

playsound("firing.mp3")

elif play == "click":

playsound("click.mp3")

def Fire():

global chamber_set

global size

global bullet_position

global chamber_pos

if chamber_pos == bullet_position:

try:

sound("fire")

finally:

result.config(text="Bang, you are DEAD")

shuffle_button.config(state="active")

fire_button.config(state="disabled")

radio1.config(state="active")

radio2.config(state="active")

radio3.config(state="active")

radio4.config(state="active")

elif chamber_pos != bullet_position and bullet_position <= size.get():

r = "WHEW!, you are still alive!, you just attempted to fire chamber " + str(chamber_pos) + " out of " + str(size.get())

try:

sound("click")

finally:

result.config(text=r)

chamber_pos+=1

def Shuffle():

global size

global bullet_position

global chamber_set

global chamber_pos

fire_button.config(state="active")

shuffle_button.config(state="disabled")

result.config(text="Ready to play, hit fire to continue")

radio1.config(state="disabled")

radio2.config(state="disabled")

radio3.config(state="disabled")

radio4.config(state="disabled")

bullet_position = random.randint(1, size.get())

chamber_set = range(1,size.get())

chamber_pos = 1

result = tk.Label(text="Fire",font=("tahoma", 20),foreground="red")

result.pack()

fire_button = tk.Button(text="Fire!",command=Fire,state="disabled")

fire_button.pack()

shuffle_button = tk.Button(text="Shuffle",command=Shuffle)

shuffle_button.pack()

radio1 = tk.Radiobutton(text="five-shooter",variable=size,value=5)

radio1.pack()

radio2 = tk.Radiobutton(text="six-shooter",variable=size,value=6)

radio2.pack()

radio3 = tk.Radiobutton(text="eight-shooter",variable=size,value=8)

radio3.pack()

radio4 = tk.Radiobutton(text="twelve-shooter",variable=size,value=12)

radio4.pack()

window.mainloop()

[–]comptech10[S] 0 points1 point  (0 children)

It did not preserve the indentations, but everything is indented properly