+ 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 Answers
+ 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
7th Jun 2020, 7:19 AM
Olivia
Olivia - avatar
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