#πŸ”’ Chess Opening Picker Not Working

29 messages Β· Page 1 of 1 (latest)

white wadi
#

Hi, it's mainly a practice project, and I want to figure out what the problem is.

hard tundraBOT
#

@white wadi

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

white wadi
#
import random

whiteopening = ["Vienna", "King's Indian Defense", "London", "Italian"]

blackopening = ["Scandi or King's Indian", "Caro or Slav", "French or Queens Pawn"]

whiterandom = random.randint(0,4)

blackrandom = random.randint(0,3)

if input("White"):
 print(whiteopening[whiterandom])

if input("Black"):
 print(blackopening[blackrandom])```
#

for some reason, this just generates "Black" and then "White" instead of waiting for input.

whole depot
#

!e

import random

whiteopening = ["Vienna", "King's Indian Defense", "London", "Italian"]
blackopening = ["Scandi or King's Indian", "Caro or Slav", "French or Queens Pawn"]

whiterandom = random.randint(0,4)
blackrandom = random.randint(0,3)

print(whiteopening[whiterandom])
print(blackopening[blackrandom])
hard tundraBOT
white wadi
#

so if I end up in a white game, I type "White" into terminal, and it spits out a white one specifically

whole depot
whole depot
white wadi
#

oh mbmb

whole depot
white wadi
#

lemmie check something really quick

#
import random

whiteopening = ["Vienna", "King's Indian Defense", "London", "Italian"]

blackopening = ["Scandi or King's Indian", "Caro or Slav", "French or Queens Pawn"]

whiterandom = random.randint(0,4)

blackrandom = random.randint(0,3)

putting = input()

if putting == "White":
    print(whiteopening[whiterandom])

if putting == "Black":
    print(blackopening[blackrandom])```
#

this worked!

#
import random

whiteopening = ["Vienna", "King's Indian Defense", "London", "Italian"]

blackopening = ["Scandi or King's Indian", "Caro or Slav", "French or Queens Pawn"]

whiterandom = random.randint(0,4)

blackrandom = random.randint(0,3)

putting = input("White or Black? Use proper capitalization!\n")

if putting == "White":
    print(whiteopening[whiterandom])

if putting == "Black":
    print(blackopening[blackrandom])```
#

fancied it up a little

muted ridge
#
import random

whiteopening = ["Vienna", "King's Indian Defense", "London", "Italian"]

blackopening = ["Scandi or King's Indian", "Caro or Slav", "French or Queens Pawn"]

while True:
    putting = input().strip().lower()
    if putting == "white":
        openings = whiteopening
    elif putting == "black":
        opening = blackopening
    else:
        continue

    i = random.randint(0, len(opening))
    print(opening[i])
    break
#

This also reprompts if user inputs something different

white wadi
#

Oh, nice!

#

tyty

muted ridge
#

You're welcome πŸ€—

muted ridge
#

So that when you add another opening to the list ..

#

.. you don't have to remember to update anything else

lime depot
hard tundraBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.