473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to create linked list automatically

Hi All,
i have this program,
================================================== ===============
class Node:
def __init__(self,name=None,next=None):
self.name=name
self.next=next

def __str__(self):
return str(self.name)

w=[]
for i in range(10):
node=Node(i)
w.append(node)

for i in range(10):
a=w[i]
if i+1>9:
b=w[9]
a.next=b

print "connection done"

def printNodes(node):
while node:
node=node.next
print node,

a=w[0]
printNodes(a)
================================================== ==================
i want to create 10 node objects and i want to connect them to each
other as linked list, so i have created two loops in first one iam
creating 10 objects and inserting them to list and in the second i
am trying to connect them, but when i try to print the connection i
got this:
================================================== =================
connection done
None

can anybody tell me how to overcome this
================================================== ==================
2. is there any way to create objects something like this
for i in range(10):
node.i=Node(i) # some thing like node1=Node(1) etc.

Please help me with this.

Dec 19 '05 #1
0 1020

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: surrealtrauma | last post by:
I want to ask what's the differences between doubly liked list and linear liked list, and also the circular doubly liked list in terms of implementation. THX
0
by: Chris Powell | last post by:
I am using Excel/Access 2000 and have two large Excel files (25,000 rows each) that I wish to create linked tables in Access rather than importing into Access. The two source Excel files change...
9
by: Valerio Daelli | last post by:
Hello everybody I have a problem with a linked list. I just get segmentation faults. Could anyone please help me? Thanks, this is the code __________________________ #include <stdio.h>...
8
by: Ted Miller | last post by:
Hi folks, I'm looking at moving a large base of C++ code to .Net under tight time constraints. The code runs in mission-critical environments, and I am extremely concerned about the loader lock...
4
by: scythemk | last post by:
Hi, I am writing a program that, everytime it executes, first loads all information from a file into a linked list of nodes, using struct to define it. After manipulating the data and receiving...
4
by: sandeep | last post by:
When we use STL which memory space it will use whither it is stack or heap or data segment How to make STL to create in heap? How to make whole container to create in heap? I think container...
19
by: Dongsheng Ruan | last post by:
with a cell class like this: #!/usr/bin/python import sys class Cell: def __init__( self, data, next=None ): self.data = data
1
by: yaarnick | last post by:
Create a linked list data structure library to hold strings. Then library should support the following linked list operations. Create() – Creates the linked list Insert() – Insert a string into the...
7
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.