I’m trying to seperate a number from a string in python. Basically I want it so if color == ‘gray’ + a number, then it will return that number. For example if color equaled ‘grey23’, it would return 23. If color equaled ‘grey’, it would trigger the else statement.
pseudo code:
# = an int
def func (color):
if color == 'gray' and a # :
return int(#)
else:
print 'pass'
color[4:]could be replaced by something more generic han the hardcoded value 4, but as “grey” (or “gray” – you use both) is hardcoded there seemed no problem with this.