Nov-08-2022, 06:42 AM
(Nov-07-2022, 05:57 PM)deanhystad Wrote: To convert 13 to 3 there is a math operation you can use, or you could convert the number to a string and only use the last digit. Here's a list of Python math operators.
https://www.w3schools.com/python/python_operators.asp.
I would not print numbers and colons, but if you want to do it that way you can. Here's info about the print command.
https://realpython.com/python-print/
I would make a string of numbers and colons, and print the string. This is a pretty exhaustive list of string operators wiith examples.
https://pythongeeks.org/strings-in-python/
print('\n'.join(f'{":".join(str(n)[-1]
for l in range(int(l/2+.5)))}{"" if l%2 else ":"}'
for n, l in (lambda n: ((l, n)
for l in range(n)))(int(input("Enter the size of the pattern:")))))
After I run the above code, a syntax error prompt out: unterminated string literal.
How can I fix the syntax error? Please check whether the code is correct.