Baekjun Python 10171 Cat Backslash Question

Asked 2 years ago, Updated 2 years ago, 22 views

Cat problem: https://www.acmicpc.net/problem/10171

http://boj.kr/3bac403ef5a64e27a7035cfec8c6b5d5 I looked on the Internet and made a code like this

But to print out the backslashes, you need two backslashes Why doesn't the first backslash in the first row and the fourth row need a backslash for output?

python

2022-09-22 11:35

1 Answers

I've made a lot of examples, so please study them.

# print('0: Of course it causes an error. Note that the contents of the error are unexpected EOF.')
# # print('\')

print('1: 2 backslashes on a string literal')
print('\\')
print('-----------')
print ('2: 1 backslash in multi-line string literal')
print('''\
''')
print('-----------')
print ('3: 2 backslashes in multi-line string literal')
print('''\\
''')
print('-----------')
print ('4: 3 backslashes in multi-line string literal')
print('''\\\
''')
print('-----------')
print ('5: 3 backslashes on multi-line string literal, 1 on the next line, 2 on the next line, and the end')
print('''\\\
\
\\''')
print('-----------')
print ('6: 5, same as middle row backslash *back* with one space')
print('''\\\
\ 
\\''')
print('-----------')
print ('7: 5, same as middle row backslash *front* with one space')
print('''\\\
 \
\\''')


2022-09-22 11:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.