Software engineering and personal development

Month: December 2021

How to Quickly Repeat String without Looping in Python

green clothes hanger
Photo by Keagan Henman on Unsplash

You have been doing math calculations since a very young age, from adding two numbers, to multiplying, dividing, and finding the square root of a number by hand.

In Python, you can also multiply a string with a number.

Yes, you read that right. You do not have to do something big, or fancy: You can just take a string and multiply it with any natural number.

You may be wondering, “What’s the result? I know what is 3 * 3, but I don’t know what’s going to be the result of 3 * ‘abc’?

Continue reading

How to Assign Multiple Variables in a Single Line in Python

assorted-color mugs on rack
Photo by Eric Prouzet on Unsplash

One of the first things that you learn when you start to program is learning how to declare a variable and assign to it a value.

For example, you are told to assign a string and then print it in a console:

Now, if we want to assign another variable in there, our intuition can be to just add a new line, and assign it there:

Continue reading

© 2024 Fatos Morina

Theme by Anders NorenUp ↑