mardi 23 novembre 2021

Exception has occurred: TypeError 'str' object does not support item assignment error in python [duplicate]

This is my code:

import random
number = ("1","2,","3","4,","5","6,","7","8,","9")
number = (random.choice(number))

import random
letter = ("a","b,","c","d,","e","f,","g","h,","i","j","k,","l","m","n","o","p","q","r","s","t","u","v","w")
letter = (random.choice(letter))

import random
cletter = ("A","B,","C","D,","E","F,","G","H,","I","J","K,","L","M","N","O","P","Q","R","S","T","U","V","W")
cletter = (random.choice(cletter))

import random
mletter = ("á","é","í","ó","ő","ö","ú","ü","ű")
mletter = (random.choice(mletter))

import random
cmletter = ("Á","É","Í","Ó","Ő","Ö","Ú","Ü","Ű")
cmletter = (random.choice(cmletter))

import random
sc = (".","?","!",":")
sc = (random.choice(sc))

import random
vsc = ("+","-","/","*","+",",","%","=","$","@","#","€")
vsc = (random.choice(vsc))

import random
lista = number + letter + cletter + mletter + cmletter + sc + vsc
**lista = random.shuffle(number + letter + cletter + mletter + cmletter + sc + vsc)**  <-- this is where it fails

print(lista)

So i have variables and each of them is a character. I want to shuffle them so that they make up a phrase. You can see what i've tried but it displays the error message seen in the title. Thanks for your help.




Aucun commentaire:

Enregistrer un commentaire