How can I run this code in Python ? Please help!!! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

7th Mar 2020, 11:29 AM
Oğuzhan Çeşmeci
Oğuzhan Çeşmeci - avatar
4 Answers
+ 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"))
7th Mar 2020, 12:36 PM
andriy kan
andriy kan - avatar
+ 4
This is a mix of python and C. If you want to run it in python, you have to rework it.
7th Mar 2020, 12:01 PM
Lothar
Lothar - avatar
+ 1
Thank you so much my friend 🙏 it is very efficiency andriy kan
7th Mar 2020, 1:48 PM
Oğuzhan Çeşmeci
Oğuzhan Çeşmeci - avatar
0
Thanks but what must I do ? Must I change some codes ? Lothar
7th Mar 2020, 12:19 PM
Oğuzhan Çeşmeci
Oğuzhan Çeşmeci - avatar