I been doing a project for a few weeks now and the final deadline has come for tommorow, I have completed all of the tasks I was set apart from one, I have been trying to do it for at least a few weeks now on my own but i just can get it wroking so if somone could help me out I would really apreciate it. The task was to create a program that saves data created to a txt file, this is my code so far;
import random
char1=str(input('Please enter a name for character 1: '))
strh1=((random.randrange(1,4))//(random.randrange(1,12))+10)
skl1=((random.randrange(1,4))//(random.randrange(1,12))+10)
print ('%s has a strength value of %s and a skill value of %s)'%(char1,strh1,skl1))
char2=str(input('Please enter a name for character 2: '))
strh2=((random.randrange(1,4))//(random.randrange(1,12))+10)
skl2=((random.randrange(1,4))//(random.randrange(1,12))+10)
print('%s has a strength value of %s and a skill value of %s'%(char1,strh1,skl1))
char1[1]="Strength now {} ".format(strh1)
char1[2]="Skill now {} ".format(skl1)
char2[1]="Strength now {} ".format(strh2)
print()
char2[2]="Skill now {}".format(skl2)
print()
myFile=open('CharAttValues.txt','wt')
for i in Char1:
myFile.write (i)
myFile.write ('\n')
for i in Char2:
myFile.write (i)
myFile.write('\n')
myFile.close()
Now I am trying to get this to write to a txt but its not working when ever i get to the end of the program where it is meant to save i get this error:
Traceback (most recent call last):
File "E:\CA2 solution.py", line 14, in <module>
char1[1]="Strength now {} ".format(strh1)
TypeError: 'str' object does not support item assignment
Im not sure how to get it to work and would really appreciate it if someone could help me to get it working in python 3.3.2 because my deadline is tomorrow and there will be bad consequences if i don't hand it in correctly, its just that i have been trying to figure it out on my own for while now and i don't have any time left so if someone could get it working I would really appreciate it, thanks so much for any help.