💡 자료형 변환을 좀 더 연구해보자!!

array = list(input())
if 'x' in array:
if array[0] == 'x':
print(1)
elif array[0] == '-' and array[1] == 'x':
print(-1)
else:
number = ' '
if array[0] != '-':
coef = array[:array.index('x')]
for val in coef:
number += val
print(int(number))
else:
coef = array[1:array.index('x')]
for val in coef:
number += val
print(-int(number))
else:
print(0)
오프라인 코테 스터디 (12/30)
참가 인원: 기우석님
if (index < 0) {
cout << 0;
}
else {
if (index == 0)
cout << 1;
else if (s[index - 1] == '+')
cout << 1;
else if (s[index - 1] == '-')
cout << -1;
else
cout << stoi(s.substr(0, index));
}