Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bug in my code
#8
(Feb-05-2017, 02:58 PM)sparkz_alot Wrote: You are getting an error, because you are telling Python to generate an error, so Python says "okee dokee here's an error"

If you don't want that, try something like:

   elif not cat.isalpha():
     print("not alpha")
     break
Just a matter of semantics, but your response "Argument should be a string", is not really accurate,  since at the beginning of your function you are converting every thing to a string.

according to the assignment question am suppose to raise a type error here is the full question

Write a program that checks if a word supplied as the argument is an Isogram. An Isogram is a word in which no letter occurs more than once.

Create a method called is_isogram that takes one argument, a word to test if it's an isogram. This method should return a tuple of the word and a boolean indicating whether it is an isogram.

If the argument supplied is an empty string, return the argument and False: (argument, False). If the argument supplied is not a string, raise a TypeError with the message 'Argument should be a string'.
Reply


Messages In This Thread
bug in my code - by sunnysude - Feb-03-2017, 08:42 PM
RE: bug in my code - by nilamo - Feb-03-2017, 09:05 PM
RE: bug in my code - by sunnysude - Feb-05-2017, 12:29 PM
RE: bug in my code - by Ofnuts - Feb-03-2017, 09:12 PM
RE: bug in my code - by sunnysude - Feb-05-2017, 12:27 PM
RE: bug in my code - by Larz60+ - Feb-05-2017, 12:29 PM
RE: bug in my code - by sparkz_alot - Feb-05-2017, 02:58 PM
RE: bug in my code - by sunnysude - Feb-05-2017, 10:50 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020