Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm Edu introduction course, string multiplication

Tags:

python

pycharm

I'm new to Python and currently running the "Introduction to Python" course for PyCharm Edu. I'm having a problem with the following task (strings -> string multiplication)

Python supports a string-by-number multiplication (but not the other way around!).

Use hello to get the "hellohellohellohellohellohellohellohellohellohello" string ("hello" repeated 10 times).

The default given code is

hello = "hello"
ten_of_hellos = hello operator 10
print(ten_of_hellos)

so I just replace the word operator with the * sign, so I have

hello = "hello"
ten_of_hellos = hello * 10
print(ten_of_hellos)

but I get an error saying "use multiplication". Any idea of what I'm doing wrong?

like image 673
njlieta Avatar asked Nov 29 '25 03:11

njlieta


1 Answers

If anyone else is completing the PyCharm Edu tutorial I noticed a problem with the string_multiplication exercise. When attempting to complete the solution an error messsage "Use multiplication" occurs. This is due to the source code of the PyCharm project. For anyone interested the solution is to go into you file system directory where the program is located:

enter image description here

Open the .py file and insert the missing "else" (highlighted in gray): enter image description here

Click the Check Task button in PyCharm Edu to see the solution is complete.

This was a solution found by GitHub user lbilger. Source

like image 155
mikeyb283 Avatar answered Dec 01 '25 17:12

mikeyb283



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!