Ask coding questions

← Back to all posts
'_io.textiowrapper' object has no attribute 'index'
LewBikes

According to everything on the entire internet there should be nothing wrong with this. I'm trying to find a specific index for string in a list. The program is based around a Product Catalogue. The task is to add items and prices to a text file, display the items nest to their prices and then allow the user to search for a specific item to find the price. Its the last part I cannot get to work.

Thanks.

Answered by Spacecraft [earned 5 cycles]
View Answer
Voters
LewBikes
Comments
hotnewtop
Spacecraft

Here's your problem. It's in the order of the variables that you're calling and returning.
Line 33:
return item, price, catalogueTXT, items, prices

Line 64:
item, price, items, prices, catalogueTXT = addItems(items, prices)

You are returning catalogueTXT into the variable items. Fix the order of these variables to be the same and it will return the correct info.

Spacecraft

Like this:
Line 33:
return item, price, items, prices, catalogueTXT

Line 64:
item, price, items, prices, catalogueTXT = addItems(items, prices)