How to start from second index for for-loop

First thing is to remember that python uses zero indexing. You can iterate throught the list except using the range function to get the indexes of the items you want or slices to get the elements. What I think is becoming confusing here is that in your example, the values and the indexes are the … Read more

Directing print output to a .txt file

Give print a file keyword argument, where the value of the argument is a file stream. We can create a file stream using the open function: From the Python documentation about print: The file argument must be an object with a write(string) method; if it is not present or None, sys.stdout will be used. And … Read more

Why is parenthesis in print voluntary in Python 2.7?

In Python 2.x print is actually a special statement and not a function*. This is also why it can’t be used like: lambda x: print x Note that (expr) does not create a Tuple (it results in expr), but , does. This likely results in the confusion between print (x) and print (x, y) in Python 2.7 However, since print is a special syntax statement/grammar construct in Python 2.x then, without … Read more

How do I remove/delete a virtualenv?

“The only way I can remove it seems to be: sudo rm -rf venv“ That’s it! There is no command for deleting your virtual environment. Simply deactivate it and rid your application of its artifacts by recursively removing it. Note that this is the same regardless of what kind of virtual environment you are using. virtualenv, venv, Anaconda … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)