Share your repls and programming experiences

← Back to all posts

This is a very simple stopwatch. Please tell me if there are any bugs or improvements.

SixBeeps (5340)

Pretty solid. You should learn about string concatenation, though. That'll come in handy for formatting it instead of just having it be vertical.


I know. But can you show me a quick summary of it right now? @niorg2606

SixBeeps (5340)

@CodeABC123 Sure.

print("string1" + "string2")

will output something like:


You can use this to combine strings or other things that can be converted to strings. For example,

fav = 7
print("My favorite number is " + str(fav))

will print out

My favorite number is 7

And, you can concatenate more than just two things at once as well:

name = "Six"
food = "potatoes"
print("My name is " + name + " and I like to eat " + food)

will give you

My name is Six and I like to eat potatoes

TypeError: unsupported operand type(s) for +: int and str @niorg2606

SixBeeps (5340)

@CodeABC123 Sorry, concatenation is a standard function in all programming languages, but I'm a little too used to the Java/C# way of doing it, so Python is a bit different than what I'm used to :)
You need to surround integers with the str() function to turn it into a string before concatenation. See fixed code above.


TypeError: ‘module’ object is not callable @niorg2606

SixBeeps (5340)

@CodeABC123 str is already built-in to the python language, so you don't need to import them I don't think


But it shows error. @niorg2606

SixBeeps (5340)

@CodeABC123 Can you show me exactly what code you put in? It seems to work fine on the repl above.


Okay, I changed the Repl code to the error code. @niorg2606

SixBeeps (5340)

@CodeABC123 Remove both import int and import str as both are already built into the language.