+ 1
Dice problem
Hello, i have trouble with a problem with dices, i tooked 4 dices with random numbers... they are all stacked on eachother and i have to find the sum of the invisible numbers ... i keep getting stuck, i will post here what i typed dice_1 = '1, 4, 3, 5, 2' dice_2 = '4, 5, 1, 3' dice_3 = '6, 1, 5, 2' dice_4 = '2, 6, 3, 4' dice_faces = '1, 2, 3, 4, 5, 6' i need to make a list with numbers that are invisibile, a list with numbers that are visible and the final, the sum of invisible faces. some help please
10 Respuestas
+ 1
Well you just answered it yourself then. You know that a die contains 1-6. You already have each die and the numbers it shows.
Put all numbers not shown in an array and sum them. Then sum all the other dice values
+ 1
Have you even attempted it? Let's see the code.
+ 1
Correct, first off, "dice_1" should be a list. When you use a for loop to loop through a string, it will just loop over each character, not each number.
"num_dice" also should be a list. append() is a list method so it can only be preformed on lists.
AliN MaD thats right!
** and when you post about errors, it's better to include the full text. It'll usually tell you exactly what's wrong and where **
0
You have to explain what "invisible numbers" are. I can see all of them
0
invisible number meaning, if the dices are stacked one on top of another, those number u dont see ... dice has 6 faces, stacked, 1st dice u see 5 numbers, 2nd only 4 ...
0
You can find the missing numbers and add them up.
Or with math. Since the sum of invisible numbers and visible numbers are 1+2+3+4+5+6, which is 21, you can 21 - the sum of visible numbers. You won't need to know what numbers are invisible.
0
well the part writting the code is hard since i started to learn python,
0
dice_1 = '1, 4, 3, 5, 2'
dice_2 = '4, 5, 1, 3'
dice_3 = '6, 1, 5, 2'
dice_4 = '2, 6, 3, 4'
dice_faces = '1, 2, 3, 4, 5, 6'
for dice_faces in dice_1:
num_dice = ''
num_dice.append(d_f)
num_dice
i keep getting a error "no attribute 'append' "
0
so i have to write them like [ 1, 2, 3, 4, 5, 6] ?
0
Understood.