Rzuć kostką!

Rzuć kostką!
Photo by Dan Horgan / Unsplash
import streamlit as st
import random

st.set_page_config(page_title="Rzuć kostką!")

st.image("https://m.media-amazon.com/images/I/61+yKqa-TmL._AC_UF350,350_QL80_.jpg")

st.write(" ")
st.write(" ")

kostka = ["K4", "K6", "K10", "K12", "K20"]
jaka_kostka = st.multiselect(label="Wybierz rodzaj kostki którą chcesz rzucić:", max_selections = 1, options = kostka)

ile_kostek = st.slider(label="Wybierz iloma kostkami chcesz rzucić:", min_value=1, max_value=10)

def rzuc_kostka(ile:int):
    wynik = random.randint(1, ile)
    st.write (f"Wynik: {wynik}")

if st.button(label="Rzuć kostką."):
    for kosteczka in jaka_kostka:
        for ilosc in range(ile_kostek):
            if kosteczka == "K4":
                rzuc_kostka(4)
            elif kosteczka == "K6":
                rzuc_kostka(6)
            elif kosteczka == "K10":
                rzuc_kostka(10)
            elif kosteczka == "K12":
                rzuc_kostka(12)
            elif kosteczka == "K20":
                rzuc_kostka(20)