Traceback errors in Python that I don't understand why I'm getting
up vote
-1
down vote
favorite
I'm getting traceback issues with my kmc.time_step(), self.evolve(events_index, dt) and my ran_int = randint(len(index)) saying that zip has no length but have no clue how to go about solving this.
Im trying to model a kinetic monte carlo simulation by checking nearest neighbours of an array to see if they have any occupied states and then either "diffusing" through if they aren't occupied (moving to the unoccupied point). If the point is occupied then diffusion cant happen so aggregation occurs. I have a bunch of conditional if statements to check these but then why I try to run I get traceback errors and have no clue why.
from numpy import *
# from scipy.signal import correlate2d
from numpy.random import randint, choice, uniform
from matplotlib.pyplot import *
class KineticMonteCarlo(object):
def __init__(self, Model):
"""Initialise a Kinetic Monte Carlo evolution method for
the given model. The model object requires the following
vectorised methods:
Model.evolve : <method>
evolves model according to given events
Model.get_rates : <method>
returns event rates
"""
# reference state
self.Model = Model
self.state = Model.state
# event rates and evolution rule
self.evolve = Model.evolve
self.get_rates = Model.get_rates
def time_step(self):
"""Perform parallel Kinetic Monte-Carlo update on model"""
# calculate transition rate fractions
rates = self.get_rates() # a k-dimensional array
probabilities = cumsum(rates, axis=0) # a k-dim array
total_rate = probabilities[-1]
probabilities /= total_rate
# choose events according to rates
u = uniform(0, 1)
events_index = sum(probabilities < u)
# generate waiting time
v = uniform(0, 1)
dt = -log(v)/total_rate
# carry out events
self.evolve(events_index, dt)
class LatticeGas(object):
def __init__(self, n_sites, density):
# initialisation of lattice gas with given density
self.size = 2*int(ceil(sqrt(n_sites)/2))
self.state = choice([0, 1], size=(self.size, self.size), p=[1-density, density])
self.time = 0.
self.aggcnt = 0
self.diffcnt = 0
self.n = 0
''' this return a a matrix of 0 and 1; 1 for occupied sites'''
def get_rates(self):
temp = 100
kb = 1.38
beta = 1/(kb * temp)
ads_rate = 0.001 * exp(- beta * 0.01)
des_rate = 0.001 * exp(- beta * 0.01)
diff_rate = 0.1 * exp(- beta * 0.35)
return array([ads_rate, des_rate, diff_rate])
def evolve(self, events_index, dt):
non_zero_m = self.state != 0
non_zeroi, non_zeroj = where(non_zero_m)
index = zip(non_zeroi, non_zeroj)
ran_ind = randint(len(index))
randi, randj = index[ran_ind]
n1 = (randi - 1) % self.size
n2 = (randj - 2) % self.size
e1 = (randj + 1) % self.size
e2 = (randj + 2) % self.size
w1 = (randj - 1) % self.size
w2 = (randj - 2) % self.size
s1 = (randi + 1) % self.size
s2 = (randi + 2) % self.size
if events_index == 0:
self.state[index[randint(len(index))]]
elif events_index == 1:
index = zip(*where(self.state == 0))
self.state[index[randint(len(index))]]
elif events_index == 2:
while True:
rand_direc = randint(4)
if rand_direc == 3 and self.state[n1, randj] == 0:
self.state[n1, randj] = 1
self.state[randi, randj] = 0
if self.state[n2, randj % self.size == 0] and self.state[n1, w1] == 0 and self.state[n1, e1] == 0:
self.diffcnt += 1
else:
self.aggcnt == 1
break
if rand_direc == 2 and self.state[randi, e1] == 0:
self.state[randi, e1] = 1
self.state[randi, randj] = 0
if self.state[n1, e1] and self.state[s1, e1] == 0 and self.state[randi, e2] == 0:
self.diffcnt += 1
else:
self.aggcnt += 1
break
elif rand_direc == 1 and self.state[s1, randj] == 0:
self.state[s1, randj] = 1
self.state[randi, randj] = 0
if self.state[s1, e1] == 0 and self.state[s1, w1] == 0 and self.state[s2, randj] == 0:
self.diffcnt += 1
else:
self.aggcount += 1
break
elif rand_direc == 0 and self.state[randi, w1] == 0:
self.state[randi, w1] = 1
self.state[randi, randj] = 0
if self.state[n1, w1] == 0 and self.state[s1, w1] == 0 and self.state[randi, w2] == 0:
self.diffcnt += 1
else:
self.aggcnt += 1
break
def show(self):
# Display current lattice configuration, with black
# and white representing whether there is a particle or not
figure(figsize=(5, 5))
imshow(self.state, interpolation="none", cmap='bone_r', vmin=0, vmax=1)
axis('off')
show()
# example of how code should work
model = LatticeGas(50, 0.1)
kmc = KineticMonteCarlo(model)
steps = 100
for i in range(steps):
kmc.time_step()
model.show()
python simulation lattice
add a comment |
up vote
-1
down vote
favorite
I'm getting traceback issues with my kmc.time_step(), self.evolve(events_index, dt) and my ran_int = randint(len(index)) saying that zip has no length but have no clue how to go about solving this.
Im trying to model a kinetic monte carlo simulation by checking nearest neighbours of an array to see if they have any occupied states and then either "diffusing" through if they aren't occupied (moving to the unoccupied point). If the point is occupied then diffusion cant happen so aggregation occurs. I have a bunch of conditional if statements to check these but then why I try to run I get traceback errors and have no clue why.
from numpy import *
# from scipy.signal import correlate2d
from numpy.random import randint, choice, uniform
from matplotlib.pyplot import *
class KineticMonteCarlo(object):
def __init__(self, Model):
"""Initialise a Kinetic Monte Carlo evolution method for
the given model. The model object requires the following
vectorised methods:
Model.evolve : <method>
evolves model according to given events
Model.get_rates : <method>
returns event rates
"""
# reference state
self.Model = Model
self.state = Model.state
# event rates and evolution rule
self.evolve = Model.evolve
self.get_rates = Model.get_rates
def time_step(self):
"""Perform parallel Kinetic Monte-Carlo update on model"""
# calculate transition rate fractions
rates = self.get_rates() # a k-dimensional array
probabilities = cumsum(rates, axis=0) # a k-dim array
total_rate = probabilities[-1]
probabilities /= total_rate
# choose events according to rates
u = uniform(0, 1)
events_index = sum(probabilities < u)
# generate waiting time
v = uniform(0, 1)
dt = -log(v)/total_rate
# carry out events
self.evolve(events_index, dt)
class LatticeGas(object):
def __init__(self, n_sites, density):
# initialisation of lattice gas with given density
self.size = 2*int(ceil(sqrt(n_sites)/2))
self.state = choice([0, 1], size=(self.size, self.size), p=[1-density, density])
self.time = 0.
self.aggcnt = 0
self.diffcnt = 0
self.n = 0
''' this return a a matrix of 0 and 1; 1 for occupied sites'''
def get_rates(self):
temp = 100
kb = 1.38
beta = 1/(kb * temp)
ads_rate = 0.001 * exp(- beta * 0.01)
des_rate = 0.001 * exp(- beta * 0.01)
diff_rate = 0.1 * exp(- beta * 0.35)
return array([ads_rate, des_rate, diff_rate])
def evolve(self, events_index, dt):
non_zero_m = self.state != 0
non_zeroi, non_zeroj = where(non_zero_m)
index = zip(non_zeroi, non_zeroj)
ran_ind = randint(len(index))
randi, randj = index[ran_ind]
n1 = (randi - 1) % self.size
n2 = (randj - 2) % self.size
e1 = (randj + 1) % self.size
e2 = (randj + 2) % self.size
w1 = (randj - 1) % self.size
w2 = (randj - 2) % self.size
s1 = (randi + 1) % self.size
s2 = (randi + 2) % self.size
if events_index == 0:
self.state[index[randint(len(index))]]
elif events_index == 1:
index = zip(*where(self.state == 0))
self.state[index[randint(len(index))]]
elif events_index == 2:
while True:
rand_direc = randint(4)
if rand_direc == 3 and self.state[n1, randj] == 0:
self.state[n1, randj] = 1
self.state[randi, randj] = 0
if self.state[n2, randj % self.size == 0] and self.state[n1, w1] == 0 and self.state[n1, e1] == 0:
self.diffcnt += 1
else:
self.aggcnt == 1
break
if rand_direc == 2 and self.state[randi, e1] == 0:
self.state[randi, e1] = 1
self.state[randi, randj] = 0
if self.state[n1, e1] and self.state[s1, e1] == 0 and self.state[randi, e2] == 0:
self.diffcnt += 1
else:
self.aggcnt += 1
break
elif rand_direc == 1 and self.state[s1, randj] == 0:
self.state[s1, randj] = 1
self.state[randi, randj] = 0
if self.state[s1, e1] == 0 and self.state[s1, w1] == 0 and self.state[s2, randj] == 0:
self.diffcnt += 1
else:
self.aggcount += 1
break
elif rand_direc == 0 and self.state[randi, w1] == 0:
self.state[randi, w1] = 1
self.state[randi, randj] = 0
if self.state[n1, w1] == 0 and self.state[s1, w1] == 0 and self.state[randi, w2] == 0:
self.diffcnt += 1
else:
self.aggcnt += 1
break
def show(self):
# Display current lattice configuration, with black
# and white representing whether there is a particle or not
figure(figsize=(5, 5))
imshow(self.state, interpolation="none", cmap='bone_r', vmin=0, vmax=1)
axis('off')
show()
# example of how code should work
model = LatticeGas(50, 0.1)
kmc = KineticMonteCarlo(model)
steps = 100
for i in range(steps):
kmc.time_step()
model.show()
python simulation lattice
5
You should show the traceback of the errors.
– b-fg
Nov 11 at 12:13
Welcome to stackoverflow! Please take the tour and read the help pages. Helpful may be "how to ask good questions" and this question checklist. Users here are way more ready to help if you provide minimal, complete, and verifiable example with some input and the desired output.
– Mikhail Stepanov
Nov 11 at 13:11
Yeah sorry about that, finally figured out that I coded this in Python 2.7 at university and then at home I have Python 3 so bits of coding didn't work like they did before I think. As when I went to uni and used Python 2.7 it was fine. Thanks for giving advice on how to try and improve my post though, appreciate it.
– Neel Patel
Nov 11 at 13:28
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm getting traceback issues with my kmc.time_step(), self.evolve(events_index, dt) and my ran_int = randint(len(index)) saying that zip has no length but have no clue how to go about solving this.
Im trying to model a kinetic monte carlo simulation by checking nearest neighbours of an array to see if they have any occupied states and then either "diffusing" through if they aren't occupied (moving to the unoccupied point). If the point is occupied then diffusion cant happen so aggregation occurs. I have a bunch of conditional if statements to check these but then why I try to run I get traceback errors and have no clue why.
from numpy import *
# from scipy.signal import correlate2d
from numpy.random import randint, choice, uniform
from matplotlib.pyplot import *
class KineticMonteCarlo(object):
def __init__(self, Model):
"""Initialise a Kinetic Monte Carlo evolution method for
the given model. The model object requires the following
vectorised methods:
Model.evolve : <method>
evolves model according to given events
Model.get_rates : <method>
returns event rates
"""
# reference state
self.Model = Model
self.state = Model.state
# event rates and evolution rule
self.evolve = Model.evolve
self.get_rates = Model.get_rates
def time_step(self):
"""Perform parallel Kinetic Monte-Carlo update on model"""
# calculate transition rate fractions
rates = self.get_rates() # a k-dimensional array
probabilities = cumsum(rates, axis=0) # a k-dim array
total_rate = probabilities[-1]
probabilities /= total_rate
# choose events according to rates
u = uniform(0, 1)
events_index = sum(probabilities < u)
# generate waiting time
v = uniform(0, 1)
dt = -log(v)/total_rate
# carry out events
self.evolve(events_index, dt)
class LatticeGas(object):
def __init__(self, n_sites, density):
# initialisation of lattice gas with given density
self.size = 2*int(ceil(sqrt(n_sites)/2))
self.state = choice([0, 1], size=(self.size, self.size), p=[1-density, density])
self.time = 0.
self.aggcnt = 0
self.diffcnt = 0
self.n = 0
''' this return a a matrix of 0 and 1; 1 for occupied sites'''
def get_rates(self):
temp = 100
kb = 1.38
beta = 1/(kb * temp)
ads_rate = 0.001 * exp(- beta * 0.01)
des_rate = 0.001 * exp(- beta * 0.01)
diff_rate = 0.1 * exp(- beta * 0.35)
return array([ads_rate, des_rate, diff_rate])
def evolve(self, events_index, dt):
non_zero_m = self.state != 0
non_zeroi, non_zeroj = where(non_zero_m)
index = zip(non_zeroi, non_zeroj)
ran_ind = randint(len(index))
randi, randj = index[ran_ind]
n1 = (randi - 1) % self.size
n2 = (randj - 2) % self.size
e1 = (randj + 1) % self.size
e2 = (randj + 2) % self.size
w1 = (randj - 1) % self.size
w2 = (randj - 2) % self.size
s1 = (randi + 1) % self.size
s2 = (randi + 2) % self.size
if events_index == 0:
self.state[index[randint(len(index))]]
elif events_index == 1:
index = zip(*where(self.state == 0))
self.state[index[randint(len(index))]]
elif events_index == 2:
while True:
rand_direc = randint(4)
if rand_direc == 3 and self.state[n1, randj] == 0:
self.state[n1, randj] = 1
self.state[randi, randj] = 0
if self.state[n2, randj % self.size == 0] and self.state[n1, w1] == 0 and self.state[n1, e1] == 0:
self.diffcnt += 1
else:
self.aggcnt == 1
break
if rand_direc == 2 and self.state[randi, e1] == 0:
self.state[randi, e1] = 1
self.state[randi, randj] = 0
if self.state[n1, e1] and self.state[s1, e1] == 0 and self.state[randi, e2] == 0:
self.diffcnt += 1
else:
self.aggcnt += 1
break
elif rand_direc == 1 and self.state[s1, randj] == 0:
self.state[s1, randj] = 1
self.state[randi, randj] = 0
if self.state[s1, e1] == 0 and self.state[s1, w1] == 0 and self.state[s2, randj] == 0:
self.diffcnt += 1
else:
self.aggcount += 1
break
elif rand_direc == 0 and self.state[randi, w1] == 0:
self.state[randi, w1] = 1
self.state[randi, randj] = 0
if self.state[n1, w1] == 0 and self.state[s1, w1] == 0 and self.state[randi, w2] == 0:
self.diffcnt += 1
else:
self.aggcnt += 1
break
def show(self):
# Display current lattice configuration, with black
# and white representing whether there is a particle or not
figure(figsize=(5, 5))
imshow(self.state, interpolation="none", cmap='bone_r', vmin=0, vmax=1)
axis('off')
show()
# example of how code should work
model = LatticeGas(50, 0.1)
kmc = KineticMonteCarlo(model)
steps = 100
for i in range(steps):
kmc.time_step()
model.show()
python simulation lattice
I'm getting traceback issues with my kmc.time_step(), self.evolve(events_index, dt) and my ran_int = randint(len(index)) saying that zip has no length but have no clue how to go about solving this.
Im trying to model a kinetic monte carlo simulation by checking nearest neighbours of an array to see if they have any occupied states and then either "diffusing" through if they aren't occupied (moving to the unoccupied point). If the point is occupied then diffusion cant happen so aggregation occurs. I have a bunch of conditional if statements to check these but then why I try to run I get traceback errors and have no clue why.
from numpy import *
# from scipy.signal import correlate2d
from numpy.random import randint, choice, uniform
from matplotlib.pyplot import *
class KineticMonteCarlo(object):
def __init__(self, Model):
"""Initialise a Kinetic Monte Carlo evolution method for
the given model. The model object requires the following
vectorised methods:
Model.evolve : <method>
evolves model according to given events
Model.get_rates : <method>
returns event rates
"""
# reference state
self.Model = Model
self.state = Model.state
# event rates and evolution rule
self.evolve = Model.evolve
self.get_rates = Model.get_rates
def time_step(self):
"""Perform parallel Kinetic Monte-Carlo update on model"""
# calculate transition rate fractions
rates = self.get_rates() # a k-dimensional array
probabilities = cumsum(rates, axis=0) # a k-dim array
total_rate = probabilities[-1]
probabilities /= total_rate
# choose events according to rates
u = uniform(0, 1)
events_index = sum(probabilities < u)
# generate waiting time
v = uniform(0, 1)
dt = -log(v)/total_rate
# carry out events
self.evolve(events_index, dt)
class LatticeGas(object):
def __init__(self, n_sites, density):
# initialisation of lattice gas with given density
self.size = 2*int(ceil(sqrt(n_sites)/2))
self.state = choice([0, 1], size=(self.size, self.size), p=[1-density, density])
self.time = 0.
self.aggcnt = 0
self.diffcnt = 0
self.n = 0
''' this return a a matrix of 0 and 1; 1 for occupied sites'''
def get_rates(self):
temp = 100
kb = 1.38
beta = 1/(kb * temp)
ads_rate = 0.001 * exp(- beta * 0.01)
des_rate = 0.001 * exp(- beta * 0.01)
diff_rate = 0.1 * exp(- beta * 0.35)
return array([ads_rate, des_rate, diff_rate])
def evolve(self, events_index, dt):
non_zero_m = self.state != 0
non_zeroi, non_zeroj = where(non_zero_m)
index = zip(non_zeroi, non_zeroj)
ran_ind = randint(len(index))
randi, randj = index[ran_ind]
n1 = (randi - 1) % self.size
n2 = (randj - 2) % self.size
e1 = (randj + 1) % self.size
e2 = (randj + 2) % self.size
w1 = (randj - 1) % self.size
w2 = (randj - 2) % self.size
s1 = (randi + 1) % self.size
s2 = (randi + 2) % self.size
if events_index == 0:
self.state[index[randint(len(index))]]
elif events_index == 1:
index = zip(*where(self.state == 0))
self.state[index[randint(len(index))]]
elif events_index == 2:
while True:
rand_direc = randint(4)
if rand_direc == 3 and self.state[n1, randj] == 0:
self.state[n1, randj] = 1
self.state[randi, randj] = 0
if self.state[n2, randj % self.size == 0] and self.state[n1, w1] == 0 and self.state[n1, e1] == 0:
self.diffcnt += 1
else:
self.aggcnt == 1
break
if rand_direc == 2 and self.state[randi, e1] == 0:
self.state[randi, e1] = 1
self.state[randi, randj] = 0
if self.state[n1, e1] and self.state[s1, e1] == 0 and self.state[randi, e2] == 0:
self.diffcnt += 1
else:
self.aggcnt += 1
break
elif rand_direc == 1 and self.state[s1, randj] == 0:
self.state[s1, randj] = 1
self.state[randi, randj] = 0
if self.state[s1, e1] == 0 and self.state[s1, w1] == 0 and self.state[s2, randj] == 0:
self.diffcnt += 1
else:
self.aggcount += 1
break
elif rand_direc == 0 and self.state[randi, w1] == 0:
self.state[randi, w1] = 1
self.state[randi, randj] = 0
if self.state[n1, w1] == 0 and self.state[s1, w1] == 0 and self.state[randi, w2] == 0:
self.diffcnt += 1
else:
self.aggcnt += 1
break
def show(self):
# Display current lattice configuration, with black
# and white representing whether there is a particle or not
figure(figsize=(5, 5))
imshow(self.state, interpolation="none", cmap='bone_r', vmin=0, vmax=1)
axis('off')
show()
# example of how code should work
model = LatticeGas(50, 0.1)
kmc = KineticMonteCarlo(model)
steps = 100
for i in range(steps):
kmc.time_step()
model.show()
python simulation lattice
python simulation lattice
edited Nov 11 at 13:26
asked Nov 11 at 11:16
Neel Patel
11
11
5
You should show the traceback of the errors.
– b-fg
Nov 11 at 12:13
Welcome to stackoverflow! Please take the tour and read the help pages. Helpful may be "how to ask good questions" and this question checklist. Users here are way more ready to help if you provide minimal, complete, and verifiable example with some input and the desired output.
– Mikhail Stepanov
Nov 11 at 13:11
Yeah sorry about that, finally figured out that I coded this in Python 2.7 at university and then at home I have Python 3 so bits of coding didn't work like they did before I think. As when I went to uni and used Python 2.7 it was fine. Thanks for giving advice on how to try and improve my post though, appreciate it.
– Neel Patel
Nov 11 at 13:28
add a comment |
5
You should show the traceback of the errors.
– b-fg
Nov 11 at 12:13
Welcome to stackoverflow! Please take the tour and read the help pages. Helpful may be "how to ask good questions" and this question checklist. Users here are way more ready to help if you provide minimal, complete, and verifiable example with some input and the desired output.
– Mikhail Stepanov
Nov 11 at 13:11
Yeah sorry about that, finally figured out that I coded this in Python 2.7 at university and then at home I have Python 3 so bits of coding didn't work like they did before I think. As when I went to uni and used Python 2.7 it was fine. Thanks for giving advice on how to try and improve my post though, appreciate it.
– Neel Patel
Nov 11 at 13:28
5
5
You should show the traceback of the errors.
– b-fg
Nov 11 at 12:13
You should show the traceback of the errors.
– b-fg
Nov 11 at 12:13
Welcome to stackoverflow! Please take the tour and read the help pages. Helpful may be "how to ask good questions" and this question checklist. Users here are way more ready to help if you provide minimal, complete, and verifiable example with some input and the desired output.
– Mikhail Stepanov
Nov 11 at 13:11
Welcome to stackoverflow! Please take the tour and read the help pages. Helpful may be "how to ask good questions" and this question checklist. Users here are way more ready to help if you provide minimal, complete, and verifiable example with some input and the desired output.
– Mikhail Stepanov
Nov 11 at 13:11
Yeah sorry about that, finally figured out that I coded this in Python 2.7 at university and then at home I have Python 3 so bits of coding didn't work like they did before I think. As when I went to uni and used Python 2.7 it was fine. Thanks for giving advice on how to try and improve my post though, appreciate it.
– Neel Patel
Nov 11 at 13:28
Yeah sorry about that, finally figured out that I coded this in Python 2.7 at university and then at home I have Python 3 so bits of coding didn't work like they did before I think. As when I went to uni and used Python 2.7 it was fine. Thanks for giving advice on how to try and improve my post though, appreciate it.
– Neel Patel
Nov 11 at 13:28
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248177%2ftraceback-errors-in-python-that-i-dont-understand-why-im-getting%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
You should show the traceback of the errors.
– b-fg
Nov 11 at 12:13
Welcome to stackoverflow! Please take the tour and read the help pages. Helpful may be "how to ask good questions" and this question checklist. Users here are way more ready to help if you provide minimal, complete, and verifiable example with some input and the desired output.
– Mikhail Stepanov
Nov 11 at 13:11
Yeah sorry about that, finally figured out that I coded this in Python 2.7 at university and then at home I have Python 3 so bits of coding didn't work like they did before I think. As when I went to uni and used Python 2.7 it was fine. Thanks for giving advice on how to try and improve my post though, appreciate it.
– Neel Patel
Nov 11 at 13:28