Im new to the python programming and I wanted to know how to write an array using python
6 13113
Im new to the python programming and I wanted to know how to write an array using python
-
arr = [1, 2, 3, 'four', [5, 6]]
-
Thanks, one more thing how do you uss a for loop to print out lines with the line number, followed by the word
-
arr = [1, 2, 3, 'four', [5, 6]]
-
Yea, just wanted to add that python has other array-like data types too:
Tuples are like lists except they can't be modified (immutable): -
myTup = (1, 2, 3, "string", (5, 6), ["string2", 9])
-
Dictionaries are like the C++ maps, they store corresponding values: -
myDict = {"val":6, "val2":8, "val3":10}
-
Thanks, one more thing how do you uss a for loop to print out lines with the line number, followed by the word
You can use enumerate(): -
lines = ["This is the first line", "This is the second line"]
-
-
for (lineNum, line) in enumerate(lines):
-
print lineNum + 1, line # enumerate returns the index which starts at zero
-
or the index function of lists: -
lines = ["This is the first line", "This is the second line"]
-
-
for line in lines:
-
print lines.index(line) + 1, line
-
Thank you so mush you been a lot of help, im gonna check it and see if it works
Thank you so mush you been a lot of help, im gonna check it and see if it works
I must ask that you please follow the Posting Guidelines for future posts on this site.
Thanks for joining.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: JW |
last post by:
Hi,
Below is a description of what I would like to do. Would someone tell
me if it is possible and if so, how?
I have an array (presumably 'large') that is mallocced in a C function
and its...
|
by: Phil |
last post by:
Hi,
I don't understand this strange behaviour:
I compile this code :
#include <Python.h>
#include"Numeric/arrayobject.h"
static PyObject *
|
by: Bo Peng |
last post by:
Dear list,
I am writing a Python extension module that needs a way to expose pieces
of a big C array to python. Currently, I am using NumPy like the following:
PyObject* res =...
|
by: Albert Tu |
last post by:
Hi,
I am learning and pretty new to Python and I hope your guys can give me
a quick start.
I have an about 1G-byte binary file from a flat panel x-ray detector; I
know at the beggining there...
|
by: Albert Tu |
last post by:
Dear there,
We have an x-ray CT system. The acquisition computer acquires x-ray
projections and outputs multiple data files in binary format (2-byte
unsigned integer) such as projection0.raw,...
|
by: Pierre Thibault |
last post by:
Hello!
I am currently trying to port a C++ code to python, and I think I am stuck
because of the very different behavior of STL iterators vs python
iterators. What I need to do is a simple...
|
by: Peter Wuertz |
last post by:
Hi,
I'm writing a C module for python, that accesses a special usb camera.
This module is supposed to provide python with data (alot of data). Then
SciPy is used to fit the data.
My question...
|
by: DeveloperX |
last post by:
I am trying to figure out how to rewrite the following chunk of code
in Python:
C source
typedef struct PF
{
int flags;
long user;
char*filename;
|
by: Santiago Romero |
last post by:
Hi :)
First of all, I must apologize for my poor english :)
I'm starting with python and pygame and for testing (and learning)
purposes I wrote an small "Map Editor" for a small game project...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
|
by: SueHopson |
last post by:
Hi All,
I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...
| |