Перевести код с паскаля на питон!
var s: string;
i, k: integer;
f: boolean;
begin
write('s = ');
readln(s);
k := 0;
f := false;
for i := 1 to length(s) - 1 do
begin
if not(f) then f := s[i] in [':', ';'];
if f and (s[i + 1] = '-') then continue;
if f and (s[i + 1] in ['(', ')', '[', ']']) then inc(k);
f := false
end;
writeln('Smiles: ', k);
readln
end.
Answers & Comments
s = input('s = ')
k = 0
f = False
for i in range(len(s) - 1):
if not(f):
f = s[i] in [':', ';']
if f and s[i + 1] == '-':
continue
if f and s[i + 1] in [')', '(', '[', ']']:
k += 1
f = False
print(f'Smiles: {k}')