python code

I’m hoping you can help me with this python code. I almost have it correct, but i keep getting an error at the end. below is the problem along with my current code. Please see if you can adjust it to make it cooperate. Thank you!!!6.6 Warm up: Parsing strings (Python 3)

(4) Using a loop, extend the program to handle multiple lines of input. Continue until the user enters q to quit. (2 pts) 


Enter input string: Jill, Allen
First word: Jill
Second word: Allen

Enter input string: Golden , Monkey
First word: Golden
Second word: Monkey

Enter input string: Washington,DC
First word: Washington
Second word: DC

Enter input string: q

my code:

while True:

  name=input(‘Enter input string: ‘)


  if(name != ‘q’):      

    name=name.replace(‘ ‘, ”)

    if ‘,’ in name:


      print(‘First word: ‘.strip(),name[0])

      print(‘Second word: ‘.strip(),name[1])




      ‘,’ not in name

      print(‘Error: No comma in string.’)

while False:


Top Answer