1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Quick Question about Python concatenation

  1. Jan 13, 2014 #1
    1. The problem statement, all variables and given/known data

    Lets say we have two strings 'movies' and ' goto'. Now the question indicates to return this combination concatenated n times, except if n is negative, it is the same as if it were 0.

    3. The attempt at a solution

    Concatenation n times would yield: n*"movies goto"

    Now if n is negative it performs in the same way you would expect 0 to perform, so would that just return None ?
    Like if n = 0, or n = -4 should it just return None?
     
  2. jcsd
  3. Jan 13, 2014 #2

    Dick

    User Avatar
    Science Advisor
    Homework Helper

    Don't you have a python interpreter to try it out in? "None" would be a plausible answer, but I don't think it does that. It returns an empty string. Also plausible.
     
  4. Jan 13, 2014 #3
    I was mainly confused with the wording but I think I got it now. Your right it should return the empty string, instead of none. Thanks.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Quick Question about Python concatenation
Loading...