String problems

Discussion in 'Python' started by lemonhead71, Nov 1, 2012.

  1. lemonhead71

    lemonhead71

    Joined:
    Oct 3, 2012
    Messages:
    3
    I been looking over these two problems forever now and I still don't know how to solve them. Please help me, I need sleep. Thank you.



    1. Write a program the accepts a sentence as input and converts each word to upper case "Pig Latin". In one version, to convert a word to Pig Latin you remove the first letter and place that letter at the end of the word. Then you append the string "ay" to the word. Here is an example:

    English: I slept most of the night

    Pig Latin: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY

    Write functions and provide testing as per usual.

    2.A 13 digit ISBN (International Standard Book Number) consists of the groups of characters:
    A prefix of 978 or 979
    the group identifier
    the publisher code
    the item number
    a single check digit

    Groups b, c, and d have a minimum length of 1, but may be longer. The groups of digits are separated by hyphens. Thus,

    978-3-16-148410-0

    is a valid ISBN number.

    Write a Python function valid_isbn that takes a string as a parameter and returns True if the string is a valid ISBN, and False otherwise.
    lemonhead71, Nov 1, 2012
    #1
    1. Advertising

  2. lemonhead71

    lemonhead71

    Joined:
    Oct 3, 2012
    Messages:
    3
    My problem relates to both questions which is I'm having trouble targeting specific sections of a string. For example, in question 1 it asks you must remove the first letter and place that letter at the end of the word. My question is how do you when a new word starts or ends in a string. I know how to target specific characters in a string but I won't know what the user types as a sentence so I also wouldn't know what character sequence makes one word. As for question 2 it says b, c, and d have a minimum length of 1 so I'm not sure how I would account for that when I make a new string with all of the 13 digit ISBN requirements.
    lemonhead71, Nov 1, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mladen Adamovic
    Replies:
    0
    Views:
    731
    Mladen Adamovic
    Dec 4, 2003
  2. Mladen Adamovic
    Replies:
    3
    Views:
    14,588
    Mladen Adamovic
    Dec 5, 2003
  3. Matt
    Replies:
    3
    Views:
    496
    Tor Iver Wilhelmsen
    Sep 17, 2004
  4. Bruce Sam
    Replies:
    15
    Views:
    7,901
    John C. Bollinger
    Nov 19, 2004
  5. Susan Baker
    Replies:
    2
    Views:
    806
    kelvSYC
    Jun 26, 2005
Loading...

Share This Page