Dec-01-2016, 09:10 AM
There's a lot to be said about your code, but I'll just mention a few points here:
Although, if I were you, I would address these things first and then post again for further advice.
- Using globals for state is bad, this is exactly what classes are for
- You should use __str__ for the string representation of a class, instead of storing it as an attribute with a weird workaround
- The way you're using for loops suggests you should take a look at nedbat's Loop Like A Native
- A lot of your code could be simplified significantly, by slightly changing your approach, and learning a few additional things about python and/or its standard library. For example:
deal=random.randint(0,12) car=deck[deal].card num=deck[deal].value image=deck[deal].draw player.append(Cards(car, num, image))
could be simplified to:
player.append(random.choice(deck))
Although, if I were you, I would address these things first and then post again for further advice.