+ 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 = []
12 Réponses
+ 1
I'm not entirely sure what it is your asking. I'd like to help but could you explain a bit better?
+ 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
+ 1
x=input()
x=[x]
print(x)
This works
+ 1
Thanks @Kiibo Ghayal @Olivia
0
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥
Thanks Kiibo
0
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥
nameST=input("Enter name :")
nameST=[nameST]
what does this code do can you explain?
0
@𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥
look here
nameST = input("please enter name : ")
# for example i enter john
now i want to make a list
john = []
0
Your welcome, I hope I was able to help a little ☺️
0
yes it helped me thank u so much @olivia
0
a=eval(input("enter your list:"))
print(list(a))
I think this will work little bit
0
backup
0
namest = []
name = input("Enter users name:")
namest.append(name)
print(namest)