Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Strings

Here is the code,

import sys

inputCheck=False

acceptableCharacters="MUI"

while inputCheck==False: initStr=input("Please input an MU string:") for char in initStr: if char in acceptableCharacters: inputCheck=True else: inputCheck=False answer=initStr rule="" while rule !='q': rule=input('Select a rule(1-4) or q to quit:') if rule == '1': if initStr[-1] is 'I': initStr += 'U' if rule is '2': initStr += initStr[1:] if rule is '3': if "III" in initStr: rule3ind = int(input("State starting position of substring III you want to replace:")) - 1 initStr = initStr[:rule3ind] + "U" + initStr[rule3ind + 3:] print("New String is:", initStr) if rule is '4': if "UU" in initStr: initStr = initStr.replace('UU', '') else: pass

print('Your new string is "' + initStr + '"')

and I wanted to be able to delete UU(in rule 4) based on an input from the user. for example: if the string is MUUIUU, i want it so that the user can delete either of them, not both UU.

Can you provide an example code to elaborate more?

Sameer Zahid I've updated the question