I am creating a guessing game program which uses alphabets in place of digits to make a puzzle out of the addition of two single-digit numbers and the answer. The player have to input a number and each digit 0 to 9 are represented by corresponding letters by position. player solves the puzzle by guessing which digits fit into the puzzle. The letters used is a-j. SO the numbers used would be 0-9. NOTE: i am only allowed to use one list, that is for the letters. My issues now are:
- How do i generate two random numbers? (So far i've manage to generate only 1 number assign to the letter)
- After generating these numbers and letters how exactly do i tell the program to pair the letter and number so that i am able to do an addition to the letter?
- How do i create a cheat sheet that only i am able to see with the randomly generated numbers and letters so that i know the answer to my guessing game?
here is my code
from random import shuffle
def getLetterMap():
stringList = list("abcdefghij")
shuffle(stringList)
return "".join(stringList)
import random
def getNum():
for i in getLetterMap():
num = random.randrange(10)
return num, i
the output should look like the photo attached.
Aucun commentaire:
Enregistrer un commentaire