samedi 19 janvier 2019

I have a questiopn about python random library [on hold]

could someone please have a look at the code below and see why it's throwing me an error in "anagram+=random_word[letter_position_random]"?

this is my code:

import random

def word_scrabble(word1,word2,word3):

    words_av = (word1,word2,word3)

    anagram = ""

    random_word = random.choice(words_av)

for letters in range(len(random_word)):

    letter_position_random = random.randrange(len(random_word))

    anagram += random_word[letter_position_random]

    random_word = random_word[:random_letter_position]+random_word[(random_letter_position + 1):]

return anagram

thanks




Aucun commentaire:

Enregistrer un commentaire