Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Nancy Melucci
Courses Plus Student 36,159 PointsStrip away tuple formatting (parens, commas) for print in Python.
For once in my life, the logic I wrote is fine. But the solution is presented with the members of the tuple not bracketed or comma'd.
So, my code prints: "The smallest number in the list is (6,) and the largest number in the list is (88,)" but I need it to go: "The smallest number in the list is 6 and the largest number in the list is 88."
is this achievable with some kind of formatting code?
thanks. So grateful for the help.
#make a list of numbers
def makealist(num):
list = [random.randint(0, 100) for x in range(num)]
return list
#small and large
def smallLarge(list):
newlist = sorted(list, key=int)
mytuple = (newlist[0], newlist[-1])
return mytuple
#proof of life
num = int(input())
mylist = makealist(num)
printlist(mylist)
theTuple = smallLarge(mylist)
print(theTuple)
small = str(theTuple[0:1])
large = str(theTuple[1:])
print('The smallest number in the list is ' + small + ' and the largest number in the list is ' + large)
2 Answers

james south
Front End Web Development Techdegree Graduate 33,271 Pointsyou can index tuples with slice notation just like lists, so instead of making new strings with your small and large variables, just string cast a direct indexing of theTuple, like "......" + str(theTuple[0]) + "........"

Nancy Melucci
Courses Plus Student 36,159 PointsAh, the slicing was overkill. Thank you so much.