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 trialRungano Matonda
3,237 Pointsquantitative assertions
Hello Any one who can help me with this problem , I am getting confused and don't know what i am doing:(Please help.
import unittest
from string_fun import is_palindrome
class PalindromeTestCase(unittest.TestCase):
def test_good_palindrome(self):
pass
def assertTrue_test_good_pandlindrome(self)
self.assertTrue == pass
def test_bad_palindrome(self):
pass
def is_palindrome(yarn):
"""Return whether or not a string is a palindrome.
A palindrome is a word/phrase that's the same in
both directions.
"""
return yarn == yarn[::-1]
2 Answers
Andreas cormack
Python Web Development Techdegree Graduate 33,011 PointsHi Rungano
A Palindrome is when the string in reverse is the same. So i pass the is_palindrome function to the assertTrue as an argument and it should return True if the string 'tacocat' is a Palindrome and the same for the assertFalse. This is how i did it.
import unittest
from string_fun import is_palindrome
class PalindromeTestCase(unittest.TestCase):
def test_good_palindrome(self):
self.assertTrue(is_palindrome("tacocat"))
def test_bad_palindrome(self):
self.assertFalse(is_palindrome("nottacocat"))
Rungano Matonda
3,237 PointsThanks a lot Andreas, you really helped me out.:)
Andrew Winkler
37,739 PointsAndrew Winkler
37,739 Pointsthank you for this +1