I am currently creating simpy.resource using the following command:
str1_counter = simpy.Resource(env, capacity=1)
But if I want to create it in a dynamic manner based on user input i.e. lets say user says the capacity(variable cap) should be 4, so in that case I tried the following:
cap = input("Enter the capacity of the store")
str1_counter = 'simpy.Resource(env, capacity=' + cap + ')'
But as you can see that instead of an instance of simpy.resource being created, the result is a string called 'simpy.Resource(env, capacity=4)'
although I would have wanted simpy.resource(env,capacity=4)
.
How do I do this?
You could do it as such;
cap = input("Enter the capacity of the store")
str1_counter = simpy.Resource(env, capacity=cap)
But also be aware of checking the input and catching errors.. for example if someone enters five
instead of 5
, what should happen?