So I essentially want to know how to do this in python:
X = int(input("How many students do you want to add? "))
for X:
studentX = str(input("Student Name: "))
Any ideas?
You don't. You'd use a list instead:
how_many = int(input("How many students do you want to add? "))
students = []
for i in range(how_many):
students.append(input("Student Name: "))
Generally speaking, you keep data out of your variable names.
globals() hacking to pipe them all into dictionaries named after each file, with the key as the machine I was polling. This means I have NO idea now how to maintain that script, and God Help Me if I ever have to repair it for any reasonI upvoted Martijn's answer, but if you need something similar to a variable name, that you can call with student1 to studentX, you can use an object:
how_many = int(input("How many students do you want to add? "))
students = {}
for i in range(how_many):
students["student{}".format(i+1)] = input("Student Name: ")
I'm not gonna suggest the exec solution...
i starts at 0, not 1, so you get student0 through to student<X-1>.i + 1, not -.
globals(), but that's a very bad idea