python

슬라이씽

bumychoi 2024. 7. 5. 17:00

# 문자 슬라이씽

in_str ="Suppose we have few words that are separated by spaces."

li =in_str.split(" ")
print(li)
count= len(li)
print(count)

# 예제
txt2 =input()
b=txt2.split('&',3)

print(b)
print(f'ex2결과:{b}')

['Suppose', 'we', 'have', 'few', 'words', 'that', 'are', 'separated', 'by', 'spaces.']
10
a&b&c&d&f
['a', 'b', 'c', 'd&f']
ex2결과:['a', 'b', 'c', 'd&f']