mercredi 16 novembre 2016

How to Randomly pick from list in the class

I want to randomly pick a weapon and i want to write the name of it but the result is not like i expect what is wrong in that code?

import random
class Dusman:

def __init__(self,name='',weapon='',armor=''):
    self.name= name
    self.weapon= weapon
    self.armor= armor

def name(self):
    a=name
    a = input("Write a name: ")

def weapon(self):
    weapon=["Sword","Axe","Topuz"]
    print(random.choice(weapon))


def print(self):
    print("Name",self.name,"Weapon: ",self.weapon,"Armor: ",self.armor)

dusman1=Dusman()
dusman1.name
dusman1.weapon
dusman1.print()




Aucun commentaire:

Enregistrer un commentaire