jeudi 3 septembre 2020

Patterns in python(need help) [duplicate]

My code:

data = {}
data["bees"] = ["RED BEE","RAINBOW BEE","YELLOW OP BEE"]
data["btype"] = ["COMMON BEE","LEGENDARY BEE","MYTHIC BEE"]
data["bmults"] = ["1","1.8","8.10"]

def hive():
    print  ("|---------------------------|")
    print  ("|        ## HIVE ##         |")
    print  ("|---------------------------|")

    i = 0
    for x in data["bees"]:
        print("")
        print("#",i,"\nNAME-:",data["bees"][i].upper(),"\nTYPE-:",data["btype"][i].upper(),"\nPOWER-:",data["bmults"][i],end ='')
        print("")
        i += 1
    print("")    
    print  ("|---------------------------|")

hive()

Output:

|---------------------------|
|        ## HIVE ##         |
|---------------------------|

# 0 
NAME-: RED BEE 
TYPE-: COMMON BEE 
POWER-: 1

# 1 
NAME-: RAINBOW BEE 
TYPE-: LEGENDARY BEE 
POWER-: 1.8

# 2 
NAME-: YELLOW OP BEE 
TYPE-: MYTHIC BEE 
POWER-: 8.10

|---------------------------|

But the output I want should be in a full box like this:

|------------------------|
|       ## HIVE ##       |
|------------------------|
|                        |
|  (here the bees name)  |
|                        |
|                        |
|------------------------|

I had made another code in which I had successfully made a box, like this:

|---------------------------|
|        ## ITEMS ##        |
|---------------------------|
|     1 .ROYAL JELLY-: 3    |
|     2 .RED EXTRACT-: 0    |
|     3 .APPLE      -: 0    |
|---------------------------|

I want the output of ## HIVES ## exactly like ## ITEMS ##

The code is the same in both cases, I just added six spaces in the apple string, like this:

a = "apple      "

But I can't even understand how to do that in hives.

I am using Python 3.8.5.

Aucun commentaire:

Enregistrer un commentaire