Answers for "AttributeError: 'str' object has no attribute 'append'"

0

AttributeError: 'str' object has no attribute 'append'

list1 = [1,2,3,4,5]
list2 = ['one','two','three','four','five']

zipped = list(zip(list1 , list2))

print(zipped)

unzipped = list( zip(*zipped) )

print(unzipped)

#for (l1,l2) in zip(list1,list2):
    #print(l1)
    #print(l2)

items =['Apple', 'Banana', 'Orange']
counts = [3,6,4]
prices = [0.99, 0.25, 0.50]

sentences = []
for (item, count, price) in zip(items, counts, prices):
    item, count, price = str(item), str(count), str(price)
    sentences = 'I bought' + count + '' + item + 's at' + price + 'cents each'
    sentences.append(sentences)

print(sentences)
Posted by: Guest on May-04-2021

Code answers related to "AttributeError: 'str' object has no attribute 'append'"

Browse Popular Code Answers by Language