-3
mappe = {10 : [10, 1]}
pair = list(mappe.values())
liste = []
liste.append((pair) + [5, 6])

--> [[10,1], 5, 6]]

how can i remove the inner brackets?

mark882
  • 25
  • 5
  • Your brackets are unbalanced. Furthermore, what is your desired result? Do you just want a list `liste = [10, 1, 5, 6]`? In that case, just write `liste = pair + [5,6]`. – eandklahn Jan 18 '22 at 14:18
  • `liste = mappe[10] + [5, 6]` or `liste = list(mappe.values())[0] + [5, 6]` – rzlvmp Jan 18 '22 at 14:20

2 Answers2

1

You can use liste.extend() instead. The function append adds the value that you pass in as a single element to a list, while extend will take an iterable object and put each item in the list as an item. Like this: liste.extend(pair + [5,6])

Nathan Roberts
  • 828
  • 2
  • 10
1

Just another approach maybe? it might do , depends on your task if you could elaborate please I'll gladly help

mappe = {10 : [10, 1]}
#pair = list(mappe.values())
pair=[]
for element in mappe:
    for x in mappe[element]:
        pair.append(x)
    
liste = pair.copy()
liste+=[5, 6]

print(liste)
DanielGzgzz
  • 118
  • 1
  • 6