title: Python: How to input 'player data' in to an seperate file... RPG Python Game
body: <p>I know you can use</p>
  
  <pre><code>f = open("data1.dat", "w")
  f.write()
  f.close()
  </code></pre>
  
  <p>But i need to know how to do that for both text and numbers</p>
  
  <pre><code>print ("Create a character! you have points to assign to strength and skills (attack,defence,health")
  name = input("What's your character's name? \n")
  print ("Two dices are thrown (A 12 and 4 sided dice) and the 12 sided dice is divided by the score on the 4 sided dice \n")
  
  attributes=("health", "strength", "attack", "defence")
  health=10
  strength=10
  attack=10
  defence=10
  
  import random
  
  dicenumber=random.randint(1,12)
  dicenumber2=random.randint(1,4)
  health = (dicenumber/dicenumber2)+ 10
  
  dicenumber=random.randint(1,12)
  dicenumber2=random.randint(1,4)
  strength = (dicenumber/dicenumber2)+ 10
  
  dicenumber=random.randint(1,12)
  dicenumber2=random.randint(1,4)
  attack = (dicenumber/dicenumber2)+ 10
  
  dicenumber=random.randint(1,12)
  dicenumber2=random.randint(1,4)
  defence = (dicenumber/dicenumber2)+ 10
  
  print ("PLAYER: ",name)
  print ("Health Points :", round(health, 2))
  print ("Strength Points :", round(strength, 2))
  print ("Attack Points :", round(attack, 2))
  print ("Defence Points :", round(defence, 2))
  
  name2 = input("What's your second character's name? \n")
  
  dicenumber=random.randint(1,12)
  dicenumber2=random.randint(1,4)
  health = (dicenumber/dicenumber2)+ 10
  
  dicenumber=random.randint(1,12)
  dicenumber2=random.randint(1,4)
  strength = (dicenumber/dicenumber2)+ 10
  
  dicenumber=random.randint(1,12)
  dicenumber2=random.randint(1,4)
  attack = (dicenumber/dicenumber2)+ 10
  
  dicenumber=random.randint(1,12)
  dicenumber2=random.randint(1,4)
  defence = (dicenumber/dicenumber2)+ 10
  
  print ("PLAYER: ",name2)
  print ("Health Points :", round(health, 2))
  print ("Strength Points :", round(strength, 2))
  print ("Attack Points :", round(attack, 2))
  print ("Defence Points :", round(defence, 2))
  </code></pre>
  
  <p>For example so the data file will be created...and it will be:</p>
  
  <p>PLAYER: Name
  Health Points : 18.0
  Strength Points : 11.0
  Attack Points : 16.0
  Defence Points : 12.0</p>
  
  <p>^something like that for both players</p>
  
  <p>Or is there a function that can hightlight/group/label my character coding:</p>
  
  <pre><code>(STATS CODING)
  
  then f = open("data1.dat, "w")
  f.write(STATS CODING)
  f.close()
  </code></pre>
  
  <p>Many Thanks, If you need more information feel free to inform me!^^</p>
  
  <p>SOLUTIONS:</p>
  
  <pre><code>with open("data1.txt", "w") as file:
  
      file.write("PLAYER: " + name)
      file.write("Health Points : " + str(round(health, 2)))
      file.write("Strength Points : " + str(round(strength, 2)))
      file.write("Attack Points : " + str(round(attack, 2)))
      file.write("Defence Points : " + str(round(defence, 2)))
  
  file.close()
  </code></pre>
  
  <p>EASY but how do i create a new line each time??</p>