Bir listedeki her elemanı bir int ile bölmek istiyorum.
myList = [10,20,30,40,50,60,70,80,90]
myInt = 10
newList = myList/myInt
Bu hata:
TypeError: unsupported operand type(s) for /: 'list' and 'int'
Neden bu hatayı aldığımı anlıyorum. Ama bir çözüm bulamadığım için sinirliyim.
Ayrıca denedi:
newList = [ a/b for a, b in (myList,myInt)]
Hata:
ValueError: too many values to unpack
Beklenen Sonuç:
newList = [1,2,3,4,5,6,7,8,9]
DÜZENLE:
Aşağıdaki kod bana beklenen sonucu verir:
newList = []
for x in myList:
newList.append(x/myInt)
Ancak bunu yapmanın daha kolay / hızlı bir yolu var mı?