title: first middle last name python
body: <pre><code># Write a program that asks the user to enter name in  
  # 'first middle last' format. THe program should print 
  # the name in format 'last,middleinitial first'
  
  name=input('Enter name in [first middle last] format:')
  space1= name.index(' ')
  first=name[0:space1]
  
  space2=name.index(' ',space1+1)
  #mandatory paramenter comes beofre optional parameter
  
  middle=name[space1+1:space2]
  last=name[space2+1:]
  newname=last+','+ middle[0]+'.'+first
  print(new name)
  </code></pre>
  
  <p>HI GUYS! I was just having some trouble understanding the program we wrote in class. I understand how we use index to find space 1 but </p>
  
  <ul>
  <li>how is this exactly working <code>space2 = name.index(' ',space1+1)</code>? </li>
  </ul>
  
  <p>Space <code>1+1</code> takes it to one space more than space <code>1</code>. </p>
  
  <ul>
  <li>How does that help in finding space <code>2</code>? </li>
  </ul>
  
  <p>APPRECIATE  YOUR HELP!</p>