Back to Problem Solutions forum
Hello Folks!!!
I've gotten stuck with the problem #45. I've had revised all the code but couldn't be able to find the error.
Looking forward for help!
Cruio_Amigo
Use this for swapping elements in lists:
arr[i], arr[j] = arr[j], arr[i]
Also I have few comments to your code:
1. You don't have to check this if dados[k] >= 52:
because any integer less than 52 by modulo 52 is going to be exact this integer.
2. This string:
return f'{[k for k in cards]}'.replace('[', '').replace(']', '').replace(',', '').replace("'", '')
Please read about join().
Or you can use unpacking operation for iterable sequences. It looks like print(*array)
I am do not understand whats wrong. may be here?
import random
for i in range(52):
j = int(random.random()*52)+1
arr_of_cards[i] , arr_of_cards[j] = arr_of_cards[j], arr_of_cards[i]
i dont understand about the integer number in the input data, what should we do with them?
The integers in the input are the random numbers you are supposed to use instead of calling random.random()
. How else would the checker know you've shuffled the cards correctly?