title: Python beginner- Repeat LINE or FOR loop
body: <p>This is my project. Please understand that I'm a beginner.</p>
  <p>Problem: I have to repeat from this line <code>for k, v in d.items() :</code> every time <strong>user_input</strong> is <strong>Y</strong> and <strong>break</strong> every time is <strong>N</strong>. I don't know if I can repeat from the line number or from the <code>for</code> or from the <code>while</code> on the previous line.</p>
  <p>Maybe I can <code>def</code> before the <code>for</code> or there's any way of repeating from wherever you want.</p>
  <p>Thank you for reading.</p>
  <p>Code:</p>
  <pre><code>elif action.lower() == 'add':
          table = input ('Select desired table number: \n - ...')
          fulltab = 'T' + table
          with open(fulltab + '.txt', 'w+') as f :
              for k, v in d.items() :
                  print(k, v)
              #print('Select codes: \n -...')
              addprod = input('Insert order. \n - ...')
              for k, v in d.items() :
                  if addprod == k[1] :
                      print('Added:', k, v)
              q = input('Add more? y/n')
              if q.lower() == 'y' : continue
              if q.lower() == 'n' : break
  </code></pre>
  <p>Full code for better understanding:</p>
  <pre><code>with open('names.txt', 'r') as r :
      f_n = r.read().splitlines()
  print(&quot;Welcome to NAME.app&quot;)
  ##############
  # USER LOGIN #
  ##############
  while True:
      name = input(&quot;&quot;&quot;
      \n - Insert name to logg in
      \n - ADD to save new user
      \n - LIST to see saved users
      \n - REMOVE to delete a user
      \n - EXIT to finish
      \n - ...&quot;&quot;&quot;)
  
      lname = name.lower()
  
      if lname == &quot;add&quot;:
          n_input = input(&quot;Name:&quot;)
          with open('names.txt', 'a') as f:
              f.write(n_input + '\n')
  
      elif lname == &quot;list&quot;:
          with open('names.txt') as f:
              print(f.read().splitlines())
              f.close()
  
      elif name in f_n:
          print(&quot;Logged as&quot;, name.upper())
          input('Welcome, press enter to continue \n')
          break
  
      elif lname == 'remove':
          rem = input(&quot;Insert user name to remove \n ...&quot;)
          with open('names.txt', 'r+') as f:
              l = f.readlines()
              l = [z for z in l if rem not in z]
          with open('names.txt', 'w') as f:
              f.writelines(l)
  
      elif lname == &quot;exit&quot;:
          exit()
  ####################
  # TABLE MANAGEMENT #
  ####################
  
  while True:
      action = input ('''
   - NEW table
      \n - ADD table
      \n - BILL
      \n - ... ''')
  
      d = {'(1) chburger': 19,'(2) bncburger': 23,'(3) plpasta': 6}
  
      if action == 'new' :
          tn = input('Insert table number \n - ...')
          name = 'T' + tn
          t = open(name + '.txt', 'w+')
          print('Done')
  
  
      elif action.lower() == 'add':
          table = input ('Select desired table number: \n - ...')
          fulltab = 'T' + table
          with open(fulltab + '.txt', 'w+') as f :
              for k, v in d.items() :
                  print(k, v)
              #print('Select codes: \n -...')
              addprod = input('Insert order. \n - ...')
              for k, v in d.items() :
                  if addprod == k[1] :
                      print('Added:', k, v)
              q = input('Add more? y/n')
              if q.lower() == 'y' : continue
              if q.lower() == 'n' : break
  
   #File as F
  
      elif action.lower() == 'bill' :
          p_b = input('Please insert number of table. \n -... ')
          with open (('T' + p_b)+ '.txt', 'r+') as p :
              tobill = 0
              for line in p : tobill = int(tobill) + int(line)
  
      
  
      #print('Total to pay:', tobill)
  
          xtra = input('Group table (+10 ppl)? y/n: \n')
          if xtra == 'y' :
              tobill = tobill + (tobill/100)*10
              print('SERVICE CHARGE ADDED.')
  
          elif xtra == 'n' : print ('Processing bill...')
          print('Total to pay:', tobill)
  
  elif action.lower() == &quot;exit&quot;:
      exit()
  </code></pre>