python - How to save results to a .txt file -


I am doing a project for a few weeks and the deadline has come for tomorrow, I have completed all the tasks I've been set aside from one, I was trying to do it for at least a few weeks on my own but I can tilt it if someone can help me, I actually Admire This task was to create a program that saves the data created in the textile file; this is my code so far;

  import randomly char1 = str (input (enter a name for '1 character:')) Strh1 = ((random.randrange (1,4)) // (random. Randrange (1,12) + 10) skl1 = ((random.randrange (1,4)) // (random.randrange (1,12)) + 10) print ('% s with the strength value of% s and % S has the skill value) '% (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 in% S strength value and the skill value of% s'% (char1, strh1, skl1)) [1] = "Now strength {}" .format (strh1) char1 [2] = "Skill now {}". Format (skl1) char2 [1] = "strength now {}". Format (strh2) print () char2 [2] = "Skill now {}". For the format (skl2) print () myFile = open ('CharAttValues.txt', 'wt') I in four: myFile.write (i) myFile.write ('\ n') for variable 2: MyFile .write (i) myFile.write ('\ n') myFile Now ()  

Now I am trying to write it on a txt, but when I do not work on reaching the end of the program, where it means error to save me :

  traceback (most recent call final): file "e: \ c 2 solution.py", line 14, & lt; Module & gt; Char1 [1] = "strength now {}". Format (strh1) Type Error: 'str' object does not support item assignment  

I'm not sure how it works and really appreciate it that someone has me Pyro 3.3. 2 can help me to work because my time limit is tomorrow and if I do not handle it properly, it will be a bad result, its only that I am trying to understand it myself and for now I have no There is no time, so if someone can work on it, then I appreciate it, thanks for any help. Thank you. Do you think python that you are trying to change the other character of char1 - which you can not do - and I'm not sure that you want to do this - because char1 is already the name of your first character - See Line 3 of your file.

I'm worn by code that you are trying to actually create data about Char 1 in character 1, if that is what you want to use the dictionary, save the data - and that The way you can use keys to name, power, and character skills - is a very unusual way of doing things.

If you use a dictionary, you will also need to change your loop

Note: There will be a better way of doing this that will be a character square - in which a sneak peek about There are all figures, and there is a specific output method - but I think that by now you are not far away.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -