我有一个简单的选举计划.以下是要求:
class Politician 以政治家的数量作为用户的投入.
num_politicians = input("The number of politicians: ")
Run Code Online (Sandbox Code Playgroud)循环和创建实例
names = []
for x in range(num_politicians):
new_name = input("Name: ")
while new_name in names:
new_name = input("Please enter another name: ")
names.append(new_name)
#### This part is the crux of my problem
### Create instances of the Politician class
#### I want to do this in a way so that i can independently
#### handle each instance when i randomize and assign votes
Run Code Online (Sandbox Code Playgroud)我看过:
但是我无法找到解决问题的方法 …