The for
loop will ask i to iterate over the values of an iterable, and you’re providing a single int
instead of an iterable
object You should iterate over range(0,len(highscores))
:
for i in (0,len(highscores))
or better, iterate directly over the array
highscores.append(wins) # Print sorted highscores print to file file = open('highscore.txt', 'w') #write to file file.write('Highscores (number of wins out of 10 games):') for line in highscores: file.write(line) file.close() #close file
Related Posts:
- How do you append to a file?
- ValueError: all the input arrays must have same number of dimensions
- TypeError: only integer arrays with one element can be converted to an index 3
- How do I copy a file in Python?
- How to declare an array in Python?
- What is the difference between Python’s list methods append and extend?
- How to open a file using the open with statement
- Using “with open() as file” method, how to write more than once? [duplicate]
- TypeError: list indices must be integers or slices, not str
- How to read a file line-by-line into a list?
- ValueError: setting an array element with a sequence
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
- TypeError: only size-1 arrays can be converted to Python scalars (matplotlib)
- Confused by python file mode “w+”
- File open and close in python
- Append values to a set in Python
- FileNotFoundError: [Errno 2] No such file or directory [duplicate]
- How to move a file in Python?
- Numpy ValueError: setting an array element with a sequence. This message may appear without the existing of a sequence?
- How do I append one string to another in Python?
- How do I create an empty array/matrix in NumPy?
- ValueError: operands could not be broadcast together with shapes (5,) (30,)
- How do I append one string to another in Python?
- numpy matrix vector multiplication
- Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- Convert pandas dataframe to NumPy array
- How do I copy a file in Python?
- size of NumPy array
- Python List vs. Array – when to use?
- How to find list intersection?
- Using Numpy Vectorize on Functions that Return Vectors
- How do I check whether a file exists without exceptions?
- Is arr.__len__() the preferred way to get the length of an array in Python?
- Call a function from another file?
- Append integer to beginning of list in Python
- Is there a NumPy function to return the first index of something in an array?
- Numpy/Python Array Value error
- Python: Array v. List
- initialize a numpy array
- Writing a list to a file with Python
- How to access the ith column of a NumPy multidimensional array?
- How can I check file size in Python?
- Dump a NumPy array into a csv file
- Python: find position of element in array
- numpy with python: convert 3d array to 2d
- Create 3D array using Python
- Python: slicing a multi-dimensional array
- Shuffle an array with python, randomize array item order with python
- Why am I getting a FileNotFoundError?
- How do I get an empty array of any size in python?
- TypeError: list indices must be integers or slices, not str
- Add single element to array in numpy
- How to create an array of bits in Python?
- How to have an array of arrays in Python
- How do I append one string to another in Python?
- Importing variables from another file?
- Make list of arrays in python
- Flask raises TemplateNotFound error even though template file exists
- How to save a dictionary to a file?
- Append a tuple to a list – what’s the difference between two ways?
- How to fix “TypeError: len() of unsized object”
- How to open a file for both reading and writing?
- How do you read a file into a list in Python?
- SSL error : routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
- append new row to old csv file python
- What is the perfect counterpart in Python for “while not EOF”
- Numpy.dot TypeError: Cannot cast array data from dtype(‘float64’) to dtype(‘S32’) according to the rule ‘safe’
- How to get the unit vector from a numpy array
- Python: Can a function return an array and a variable?
- .write not working in Python
- Creating files and directories via Python
- numpy-equivalent of list.pop?
- Using numpy to build an array of all combinations of two arrays
- Efficiently sorting a numpy array in descending order?
- How to plot an array in python?
- How to create a numpy array of all True or all False?
- How to create a numpy array of lists?
- Removing nan values from an array
- How to delete a specific line in a file?
- Numpy – add row to array
- How often does python flush to a file?
- How to open every file in a folder
- Is there any numpy group by function?
- List append() in for loop
- TypeError: expected str, bytes or os.PathLike object, not _io.TextIOWrapper
- How do I merge lists in python? [duplicate]
- Counting array elements in Python
- Loading and parsing a JSON file with multiple JSON objects
- Mean Squared Error in Numpy?
- numpy array concatenation error: 0-d arrays can’t be concatenated
- Convert a 1D array to a 2D array in numpy
- How to find out whether a file is at its `eof`?
- inverting image in Python with OpenCV
- How to print the full NumPy array, without truncation?
- Sorting arrays in NumPy by column
- How is Python’s List Implemented?
- Hashing arrays in Python
- How to append new data onto a new line
- Python IOError: File not open for reading
- Shuffle an array with python, randomize array item order with python