Python For Loop

A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).

This is less like the for keyword in other programming languages, and works more like an iterator method as found in other object-orientated programming languages.

With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.

Example:

fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)

Airtable python api

Asked by wiki @ & viewed by 18 persons

Python and the Airtable API Can anyone find an exampple of the API for Airtable.com being used in python. There …

Automate windows with python

Asked by wiki @ & viewed by 14 persons

Python code to automate desktop activities in windows I want to automate desktop activities in Windows environment using Python. How …

Email with python

Asked by wiki @ & viewed by 16 persons

How to send an email with Python? This code works and sends me an email just fine: import smtplib #SERVER …

Python log exception stack trace

Asked by wiki @ & viewed by 16 persons

How do I log a Python error with debug information? I am printing Python exception messages to a log file …

Pubnub python

Asked by wiki @ & viewed by 12 persons

Unable to get result of pubnub.time() in Python How do I get the result of pubnub.time() when called? This is …

10 2 python

Asked by wiki @ & viewed by 12 persons

Difference between “//” and “/” in Python 2 [duplicate] This question already has answers here: What is the difference between …

1 11 111 pattern in python

Asked by wiki @ & viewed by 14 persons

Python Logic - decreasing set of 1's using for loops to create triangle This is for a CS101 type Python …

How to deploy python code

Asked by wiki @ & viewed by 15 persons

How to deploy python script? This might sound like a very open ended question, but I am a python enthusiast, …

Airtable api python

Asked by wiki @ & viewed by 12 persons

Python and the Airtable API Can anyone find an exampple of the API for Airtable.com being used in python. There …

1 2 in python

Asked by wiki @ & viewed by 12 persons

Understanding slice notation I need a good explanation (references are a plus) on Python's slice notation. To me, this notation …

Read data from azure data lake using python

Asked by wiki @ & viewed by 8 persons

Python code to access Azure Data Lake Store I 'm looking at Microsoft Documentation here and here, I have created …

15 puzzle problem solution in python

Asked by wiki @ & viewed by 16 persons

Python 15 puzzle solver with A* algorithm can't find a solution for most cases I've been trying to write a …

15 puzzle python code

Asked by wiki @ & viewed by 11 persons

Python 15 puzzle solver with A* algorithm can't find a solution for most cases I've been trying to write a …

How to log errors in python

Asked by wiki @ & viewed by 16 persons

How do I log a Python error with debug information? I am printing Python exception messages to a log file …

Secure python code

Asked by wiki @ & viewed by 11 persons

How do I protect Python code from being read by users? I am developing a piece of software in Python …

1 2 3 4 in python

Asked by wiki @ & viewed by 12 persons

Python: “1-2-3-4” to [1, 2, 3, 4] What is the best way to convert a string on the format "1-2-3-4" …

Python windows automation

Asked by wiki @ & viewed by 13 persons

Python code to automate desktop activities in windows I want to automate desktop activities in Windows environment using Python. How …

Python read gmail

Asked by wiki @ & viewed by 14 persons

Reading Gmail Email in Python I am attempting to create a simple script to check my Gmail for emails with …

Python memory monitor

Asked by wiki @ & viewed by 12 persons

How do I profile memory usage in Python? I've recently become interested in algorithms and have begun exploring them by …

0x80070643 python

Asked by wiki @ & viewed by 10 persons

0x80070643 error while installing Python 3.6 I'm actually using Python for an audio steganography project but I have some troubles. …

Most viewed questions


Python strftime milliseconds

Asked by wiki @ & viewed by 200 persons

Format a datetime into a string with milliseconds I want to have a datetime string from the date with milliseconds. …

What does the percent sign mean in python

Asked by wiki @ & viewed by 136 persons

What does the percentage sign mean in Python In the tutorial there is an example for finding prime numbers: >>> …

Self keyword in python

Asked by wiki @ & viewed by 134 persons

What is the purpose of the word 'self'? What is the purpose of the self word in Python? I understand …

Check object type python

Asked by wiki @ & viewed by 132 persons

Determine the type of an object? Is there a simple way to determine if a variable is a list, dictionary, …

Correlation matrix python

Asked by wiki @ & viewed by 131 persons

Plot correlation matrix using pandas I have a data set with huge number of features, so analysing the correlation matrix …

Alphabetical sort python

Asked by wiki @ & viewed by 131 persons

Python data structure sort list alphabetically I am a bit confused regarding data structure in python; (),[], and {}. I …

Python random

Asked by wiki @ & viewed by 127 persons

Generate random integers between 0 and 9 How can I generate random integers between 0 and 9 (inclusive) in Python? …

Python one line for loop

Asked by wiki @ & viewed by 124 persons

Python one-line “for” expression I'm not sure if I need a lambda, or something else. But still, I need the …

Python create dataframe from list

Asked by wiki @ & viewed by 124 persons

Python: create a pandas data frame from a list I am using the following code to create a data frame …

How to add a column to dataframe python

Asked by wiki @ & viewed by 123 persons

Adding new column to existing DataFrame in Python pandas I have the following indexed DataFrame with named columns and rows …

Why we use self in python

Asked by wiki @ & viewed by 116 persons

What is the purpose of the word 'self'? What is the purpose of the self word in Python? I understand …

Shape 0 python

Asked by wiki @ & viewed by 115 persons

x.shape[0] vs x[0].shape in NumPy Let say, I have an array with x.shape = (10,1024) when I try to print …

Python print working directory

Asked by wiki @ & viewed by 113 persons

Find current directory and file's directory [duplicate] This question already has answers here: How do you properly determine the current …

Image shape python

Asked by wiki @ & viewed by 110 persons

Python OpenCV2 (cv2) wrapper to get image size? How to get the size of an image in cv2 wrapper in …

Interface grafica python

Asked by wiki @ & viewed by 108 persons

Como criar interface gráfica em Python? [duplicada] Essa pergunta já tem uma resposta aqui: É possível criar interfaces gráficas para …