+ 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
12 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
0
namest = [] name = input("Enter users name:") namest.append(name) print(namest)
27th Aug 2024, 6:29 AM
rustemrustemrustem agamyradowagamyradow
rustemrustemrustem agamyradowagamyradow - avatar