Python Forum
How to call the stored values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to call the stored values
#5
I tried to keep your logic.

# The idea is to have the player play against the computer without knowing the values of their choices
# then to guess the high middle low choice

import random

d_moves = {}


def alpha(**kwargs):
    if(d_moves):
        # Merge if d_moves already exists
        return {**d_moves, **kwargs}
    return kwargs


#def bravo(*values):
#    bravo.values = values or bravo.values
#    return bravo.values
#bravo.values =()


d_moves = alpha(a=5, b=3, c=2)
d_moves = alpha(d=2, e=5, f=3)


def choice():
    choice = ""
    while choice != "a" and choice != "b" and choice != "c":
        print("choose a, b or c")
        choice = input()

    # Get the int using a,b,c as key of the dict
    choice = d_moves[choice]
    return choice


def check(choice):
    compmove = ('d', 'e', 'f')
    comp = random.choice(compmove)
    comp = d_moves[comp]

    if (choice) == (comp):
        print("draw")
        print(choice)
        print(comp)

    elif (choice) > (comp):
        print("player")
        print(choice)
        print(comp)

    elif (choice) < (comp):
        print("comp")
        print(choice)
        print(comp)


def loop():
    guesses = 0
    while guesses < 6:
        move = choice()
        check(move)
        guesses = guesses + 1


loop()
Reply


Messages In This Thread
How to call the stored values - by Dieselkaine - Jul-04-2018, 08:21 PM
RE: How to call the stored values - by ichabod801 - Jul-04-2018, 08:54 PM
RE: How to call the stored values - by gontajones - Jul-04-2018, 08:55 PM
RE: How to call the stored values - by Dieselkaine - Jul-04-2018, 09:19 PM
RE: How to call the stored values - by gontajones - Jul-04-2018, 09:53 PM
RE: How to call the stored values - by Dieselkaine - Jul-04-2018, 10:12 PM
RE: How to call the stored values - by gontajones - Jul-04-2018, 10:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python call stored procedure mg24 2 1,115 Oct-18-2022, 02:19 AM
Last Post: mg24
  python call stored procedure with two parameter mg24 4 1,601 Sep-27-2022, 05:02 AM
Last Post: deanhystad
  How do loop over curl and 'put' different values in API call? onenessboy 0 1,248 Jun-05-2022, 05:24 AM
Last Post: onenessboy
  Values not updating for restful call boomramada 0 1,671 Mar-13-2021, 01:08 PM
Last Post: boomramada
  How to call the values at the end of a text string? Dieselkaine 2 3,004 Jul-02-2018, 08:47 PM
Last Post: Dieselkaine

Forum Jump:

User Panel Messages

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