in your first snippet you need to indent the print 2 levels - to be indented one level compared to inner loop.
in the second snippet the syntax with
Here is the docs for string format syntax
Here is comparison between old-style and str.format() method: https://pyformat.info/
for i in range(1, 11): for j in range(n): print (i * j)few observations:
- you may want to change the second for loop to start from
1
and includen
. Currently it will start from 0 and will not include n
- you may want to change the print function to display also bot multiples not just the result.
in the second snippet the syntax with
d%
that you ask about is called string formatting. that is so called old-styled string formatting. there is newer str.format()
method and from 3.6+ - also f-stringsHere is the docs for string format syntax
Here is comparison between old-style and str.format() method: https://pyformat.info/
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs