Quick way (Probably too much horizontal space though):
n=int(input('Please enter a positive integer between 1 and 15: ')) for row in range(1,n+1): for col in range(1,n+1): print(row*col, end="\t") print()
Better way:
n=int(input('Please enter a positive integer between 1 and 15: ')) for row in range(1,n+1): print(*("{:3}".format(row*col) for col in range(1, n+1)))
And using f-strings (Python3.6+)
for row in range(1, n + 1): print(*(f"{row*col:3}" for col in range(1, n + 1)))
Related Posts:
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
- Best way to convert string to bytes in Python 3?
- Best way to convert string to bytes in Python 3?
- TypeError: not all arguments converted during string formatting python
- Convert bytes to a string
- How to print like printf in Python3?
- How can I concatenate str and int objects?
- How do I format a string using a dictionary in python-3.x?
- Replacing a character from a certain index
- How to convert ‘binary string’ to normal string in Python3?
- How to compare individual characters in two strings in Python 3
- Python cant convert ‘list’ object to str error [closed]
- Using strip() to clean up a string
- Python – difference between two strings
- SyntaxError: unexpected EOF while parsing
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
- How to prettyprint a JSON file?
- How to install pip with Python 3?
- Import Error: No module named numpy
- Relative imports in Python 3
- Dijkstra’s algorithm in python
- Pythonic way to create a long multi-line string
- Does Python have a string ‘contains’ substring method?
- How do I append one string to another in Python?
- Using Python 3 in virtualenv
- Random string generation with upper case letters and digits
- WinError 2 The system cannot find the file specified (Python)
- hashlib.md5() TypeError: Unicode-objects must be encoded before hashing
- Could not find a version that satisfies the requirement tensorflow
- Local variable referenced before assignment?
- AttributeError: ‘module’ object has no attribute ‘urlopen’
- Can’t fix “zipimport.ZipImportError: can’t decompress data; zlib not available” when I type in “python3.6 get-pip.py”
- Python: maximum recursion depth exceeded while calling a Python object
- ‘method’ object is not subscriptable. Don’t know what’s wrong
- Split a string into 2 in Python
- Best way to strip punctuation from a string
- How to upgrade pip3?
- TypeError: Missing 1 required positional argument: ‘self’
- What is __pycache__?
- SystemError: Parent module ” not loaded, cannot perform relative import
- TypeError: ‘<=' not supported between instances of 'str' and 'int' [duplicate]
- TypeError: unsupported operand type(s) for -: ‘str’ and ‘int’
- How to Read .txt in Pandas
- TypeError: can’t use a string pattern on a bytes-like object in re.findall()
- Pinging servers in Python
- Add Legend to Seaborn point plot
- How to pass arguments to a Button command in Tkinter?
- How to remove specific substrings from a set of strings in Python?
- Type error: cannot convert the series to
- Convert columns to string in Pandas
- How to remove punctuation marks from a string in Python 3.x using .translate()?
- Subplot for seaborn boxplot
- How to delete a character from a string using Python
- enumerate() for dictionary in python
- Why Python 3.6.1 throws AttributeError: module ‘enum’ has no attribute ‘IntFlag’?
- How to use sys.exit() in Python
- How to check if a string is a substring of items in a list of strings?
- installing urllib in Python3.6
- What is sys.maxint in Python 3?
- Finding all possible permutations of a given string in python
- How can I install Python’s pip3 on my Mac?
- How to convert string to binary?
- Converting from a string to boolean in Python?
- What is the meaning of ‘for _ in range()
- How do I check if there are duplicates in a flat list?
- How can I print variable and string on same line in Python?
- Python: AttributeError: ‘_io.TextIOWrapper’ object has no attribute ‘split’
- Convert hex string to int in Python
- Youtube_dl : ERROR : YouTube said: Unable to extract video data
- How to concatenate items in a list to a single string?
- AttributeError: ‘list’ object has no attribute ‘lower’ gensim
- Anaconda Installed but Cannot Launch Navigator
- ImportError: No module named ‘yaml’
- TypeError: ‘_io.TextIOWrapper’ object is not subscriptable
- How to print multiple lines of text with Python
- How to get a function name as a string?
- How do I run pip on python for windows?
- Need to install urllib2 for Python 3.5.1
- ImportError: No module named ‘xlrd’
- How to repeat a string with spaces?
- Moving Average Pandas
- What does {0} mean in this Python string?
- Tab Error in Python
- Python 3.5.1 urllib has no attribute request
- How do I convert a string to a double in Python?
- matplotlib: plot multiple columns of pandas data frame on the bar chart
- How can I copy a Python string?
- Edit Distance in Python
- Why do I get this error “TypeError: ‘method’ object is not iterable”?
- What is the purpose of dollar sign in this Python3 string formatting expression?
- How to get ° character in a string in python?
- What is the meaning of “int(a[::-1])” in Python?
- Getting a name error when trying to input a string [duplicate]
- Mutable strings in Python
- Error loading MySQLdb module: No module named ‘MySQLdb’
- How do you switch between python 2 and 3, and vice versa?
- Iterating over dictionary items(), values(), keys() in Python 3
- Undefined variable error in function
- Python 3 integer division [duplicate]