Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Draft saved
Draft discarded
Cancel
9
  • was your answer judged as incorrect? I think the provided solution just have an intention of exposing some knowledge of string concatenation to the user; and it is indeed the purpose of an exercise. Commented Nov 5, 2014 at 8:09
  • 5
    I much prefer your code; adding up strings by concatenation should generally be avoided, and the single line will be more efficient than an explicit loop. My only issue is with shadowing str, but I guess you were provided with the function definition. Commented Nov 5, 2014 at 8:10
  • as @YohanesKhosiawan许先汉 wrote. The answer uses concepts likes ranges and a for loop and is much easier to expand, e.g. other delimiters between the copies. Your solution is clean for the purpose but hides the functionality a bit. Commented Nov 5, 2014 at 8:13
  • 2
    @GingerPlusPlus using str as a variable name prevents you from accessing the built-in type. Commented Nov 5, 2014 at 9:08
  • 3
    Basically, if you understand what the other code is doing (it's always worth learning from alternative approaches and implementations), don't worry about it. You wrote code that met the spec and passed the tests: good job, that's programming. Commented Nov 5, 2014 at 9:49

lang-py

AltStyle によって変換されたページ (->オリジナル) /