How to change st in a list | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

How to change st in a list

i want to put a couple of items in a list into one for example A=[s,a,r,a] How can i change it to [sara]

5th Oct 2017, 10:16 AM
Amireza ta
Amireza ta - avatar
6 Antworten
0
A=[s,a,r,a] means s,a,r,a, are 4 variables. for characteruse '' in each character. A = ['s','a','r','a'] Here is your solution. def change(list): reasult = '' for i in list: reasult+=i return reasult A = ['s','a','r','a'] b=change(A) c=[] c.append(b) print(c) OUTPUT: ['sara']
5th Oct 2017, 5:31 PM
Abu Sayem
0
b=change(A) b is not defined
5th Oct 2017, 6:27 PM
Amireza ta
Amireza ta - avatar
0
What do you mean by b is not defined. b will keep the value change function returns.
5th Oct 2017, 6:44 PM
Abu Sayem
0
there is no function with change change(A) doesnt work
5th Oct 2017, 6:48 PM
Amireza ta
Amireza ta - avatar
5th Oct 2017, 6:49 PM
Abu Sayem
0
can i have your number??
5th Oct 2017, 6:56 PM
Amireza ta
Amireza ta - avatar