str=input("input")
count=0
for i in str:
???
A or B is entered (for example, AAABBABABAB
or BBBAAABABABA
).
I want to calculate it like the count value 12323454321
If the same character appears consecutively, increase the count value by 1 and decrease the count value by 1 if the character is wrong
I want to make a for door, but it's hard because I'm a Ask how to construct a for statement...
string = input ('input')
pre = string[0]
count = 0
for s in string:
if s == pre:
count += 1
else:
count += -1
pre = s
print(count, end='')
556 Who developed the "avformat-59.dll" that comes with FFmpeg?
818 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
564 PHP ssh2_scp_send fails to send files as intended
558 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
578 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.