0
How can I run this code in Python ? Please help!!!
Hi everyone I want to show at the screen 10 row and 10 column asteriks from 1 to 10 which that asteriks must shown only at fully divided numbers. But I can't run that codes. How can I run it ? https://code.sololearn.com/cnc2AVkZ8M84/?ref=app
4 odpowiedzi
+ 2
at least you can replace stdio.write() with print() and remove import of stdio
like this:
import sys
n = int(sys.argv[1])
for i in range (1, n + 1):
for j in range (1, n+1):
if ( i % j == 0) or ( j % i == 0):
print('*', end='')
else:
print(' ', end='')
print()
also you can make your code shorter like this:
import sys
n = int(sys.argv[1])
for i in range (1, n + 1):
print(*('*' if i % j == 0 or j % i == 0 else ' ' for j in range(1, n+1)))
You can try it:
https://code.sololearn.com/cE0zuvy4xIiH
you can get user input using
n = int(input("Enter number"))
+ 4
This is a mix of python and C. If you want to run it in python, you have to rework it.
+ 1
Thank you so much my friend 🙏 it is very efficiency andriy kan
0
Thanks but what must I do ? Must I change some codes ? Lothar