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) 

Ex:

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: ‘)

  print(“n”.rstrip(“n”))

  if(name != ‘q’):      

    name=name.replace(‘ ‘, ”)

    if ‘,’ in name:

      name=name.split(‘,’)

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

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

      print(“n”.rstrip(“n”))

      print()

    else:

      ‘,’ not in name

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

while False:

  print()

Top Answer

Hi there! Click one of our representatives below and we will get back to you as soon as possible.

Chat with us on WhatsApp