python - How to return a variable multiple times and create an array -


i creating shop/inventory system python rpg , return several variables function in shop. create 3-5 items every time shop visited right if print 1 of returned variables print info last item created. need able store each unique items values in array each item can called on not last one.

if plus == 0: #if item made has plus equal nothing                         if has_add == 'yes': #if has add                             if item_type == 'weapon':  #if weapon (no plus, has add, weapon)                                    created_item = print(str(count) + ". " + quality + " " + wep_adj + " " + "" + weapon_type + " of " + wep_add + "..........attack: " + str(weapon_attack) + " price: " + str(wep_price)) #print                             if item_type == 'armor': #if armor (no plus, has add, armor)                                 created_item = print(str(count) + ". " + quality + " " + arm_adj + " " + " " + armor_piece + " of " + arm_add + "..........armor: " + str(armor_defense) + " hp: " + str(armor_hp) + " price: " + str(arm_price)) #print                         else: # if item doesnt have add                             if item_type == 'weapon':  #if weapon (no plus, no add, weapon)                                 created_item = print(str(count) + ". " + quality + " " + wep_adj + " " + "" + weapon_type + "..........attack: " + str(weapon_attack) + " price: " + str(wep_price)) #print                             if item_type == 'armor': # if armor (no plus, no add, armor)                                 created_item = print(str(count) + ". " + quality + " " + arm_adj + " " + " " + armor_piece  + "..........armor: " + str(armor_defense) + " hp: " + str(armor_hp) + " price: " + str(arm_price)) #print                     else: #if item made has plus                          if has_add == 'yes': # if has add                             if item_type == 'weapon': # if weapon (has plus, has add, weapon)                                 created_item = print(str(count) + ". " + quality + " " + wep_adj + " " + "" + weapon_type + " of " + wep_add + " +" + str(plus) + "..........attack: " + str(weapon_attack) + " price: " + str(wep_price)) #print                             if item_type == 'armor': #if armor (has plus, has add, armor)                                 created_item = print(str(count) + ". " + quality + " " + arm_adj + " " + " " + armor_piece + " of " + arm_add + " +" + str(plus)  + "..........armor: " + str(armor_defense) + " hp: " + str(armor_hp) + " price: " + str(arm_price)) #print                         else: # if doesnt have add                             if item_type == 'weapon': #if weapon (has plus, no add, weapon)                                 created_item = print(str(count) + ". " + quality + " " + wep_adj + " " + "" + weapon_type + " +" +  str(plus) + "..........attack: " + str(weapon_attack) + " price: " + str(wep_price)) #print                             if item_type == 'armor': #if armor (has plus, no add, armor)                                 created_item = print(str(count) + ". " + quality + " " + arm_adj + " " + " " + armor_piece + " +" + str(plus)  + "..........armor: " + str(armor_defense) + " hp: " + str(armor_hp) + " price: " + str(arm_price)) #print                      if item_type == 'weapon': #allows info out of function                         return (created_item, count, quality, wep_adj, weapon_type, wep_add, plus, weapon_attack, wep_price, randvar)                     else:                         return (created_item, count, quality, arm_adj, armor_piece, arm_add, plus, armor_defense, arm_price, armor_hp)                    while items_amount > items_made: #if we've made 3-5 items, stop making them                     new_item, count, quality, adj, piece, add, plus, stat, price, other_stat = make_item()                     items_made += 1 #increase items made every time 1 made                     count += 1                 return (new_item, count, quality, adj, piece, add, plus, stat, price, other_stat)                      new_item, count, quality, adj, piece, add, plus, stat, price, other_stat = generate_items() #call function make items when shop visited             print(new_item, count, quality, adj, piece, add, plus, stat, price, other_stat) 

since code immense don't want link entirety of relevant code. relevant this:

while items_amount > items_made: #if we've made 3-5 items, stop making them                     new_item, count, quality, adj, piece, add, plus, stat, price, other_stat = make_item()                     items_made += 1 #increase items made every time 1 made                     count += 1                 return (new_item, count, quality, adj, piece, add, plus, stat, price, other_stat) 

i need able return them arrays instead of variables

insert tuples list:

items = list() while items_amount > items_made:  # if we've made 3-5 items, stop making them     new_item, count, quality, adj, piece, add, plus, stat, price, other_stat = make_item()     items_made += 1  # increase items made every time 1 made     count += 1     items.append((new_item, count, quality, adj, piece, add, plus, stat, price, other_stat))  return items 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -