variable defining phyton | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

variable defining phyton

Hi How can we use the value of one variable as the name of another variable? for example nameST = input("please enter student name :") i want to create a list whose name is the variable value nameST nameST value that user enters fo nameST = []

7th Jun 2020, 7:08 AM
nima rasi
11 Respostas
+ 1
I'm not entirely sure what it is your asking. I'd like to help but could you explain a bit better?
7th Jun 2020, 7:14 AM
Olivia
Olivia - avatar
+ 1
šŠš¢š¢š›šØ š†š”ššš²ššš„ Sorry I misread. nima x To make a list you have to write: Name=[elements] If you do what Kiibo has said then the name of your list will be the value of nameST and so will the [0] element
7th Jun 2020, 7:24 AM
Olivia
Olivia - avatar
+ 1
x=input() x=[x] print(x) This works
7th Jun 2020, 7:29 AM
Olivia
Olivia - avatar
+ 1
Thanks @Kiibo Ghayal @Olivia
7th Jun 2020, 7:35 AM
nima rasi
0
šŠš¢š¢š›šØ š†š”ššš²ššš„ nameST=input("Enter name :") nameST=[nameST] what does this code do can you explain?
7th Jun 2020, 7:21 AM
nima rasi
0
@šŠš¢š¢š›šØ š†š”ššš²ššš„ look here nameST = input("please enter name : ") # for example i enter john now i want to make a list john = []
7th Jun 2020, 7:24 AM
nima rasi
0
Your welcome, I hope I was able to help a little ā˜ŗļø
7th Jun 2020, 7:35 AM
Olivia
Olivia - avatar
0
yes it helped me thank u so much @olivia
7th Jun 2020, 7:37 AM
nima rasi
0
a=eval(input("enter your list:")) print(list(a)) I think this will work little bit
8th Jun 2020, 8:17 AM
怊A$# ā˜† $ING#怋
怊A$# ā˜† $ING#怋 - avatar
0
backup
9th Jun 2020, 4:41 AM
Harri