Note that there are some explanatory texts on larger screens.

plurals
  1. POmake output look nice and clean in python
    text
    copied!<p>I'm really new to python. I was just wondering, how do you make the output to look nice and clean? because my output for search and sort functions looks like this</p> <pre><code>"[{u'id': 1, u'name': u'ProPerformance', u'price': u'$2000', u'type': u'Treadmill'}, {u'id': 2, u'name': u'Eliptane', u'price': u'$1500', u'type': u'Elliptical'}, {u'id': 5, u'name': u'SupremeChest', u'price': u'$4000', u'type': u'Chest Press'}, {u'id': 12, u'name': u'PowerCage', u'price': u'$5000', u'type': u'Squat'}] ---Sorted by Type--- [{u'id': 5, u'name': u'SupremeChest', u'price': u'$4000', u'type': u'Chest Press'}, {u'id': 2, u'name': u'Eliptane', u'price': u'$1500', u'type': u'Elliptical'}, {u'id': 12, u'name': u'PowerCage', u'price': u'$5000', u'type': u'Squat'}, {u'id': 1, u'name': u'ProPerformance', u'price': u'$2000', u'type': u'Treadmill'}] </code></pre> <p>I kinda want my output to look something like this </p> <pre><code>"RunPro $2000 Treadmill Eliptane $1500 Elliptical SupremeChest $4000 Chest Press PowerCage $5000 Squat” ---Sorted by Type--- RunPro $2000 Chest Press Eliptane $1500 Elliptical SupremeChest $4000 Squat PowerCage $5000 Treadmill” </code></pre> <p>Can someone please help me? I've been trying to figure this out for like an hour and it's really stressing me out any help would be greatly appreciated. here’s my code </p> <pre><code>def searchEquipment(self,search): foundList = [] workoutObject =self.loadData(self.datafile) howmanyEquipment = len(workoutObject["equipment"]) for counter in range(howmanyEquipment): name = workoutObject["equipment"][counter]["name"].lower() lowerCaseSearch = search.lower() didIfindIt = name.find(lowerCaseSearch) if didIfindIt &gt;= 0: foundList.append(workoutObject["equipment"][counter]) return foundList def sortByType(self,foundEquipment): sortedTypeList = sorted(foundEquipment, key=itemgetter("type")) return sortedTypeList </code></pre> <p>I tried to replace <code>foundList.append(workoutObject["equipment"][counter])</code> to print <code>workoutObject["equipment"][counter]["name"]</code> but it messes up my sort function.</p> <p>thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload