473,382 Members | 1,420 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,382 software developers and data experts.

little problem with list.reverse() function

>>> a = [[1,2],[2,3],[4,5]]
print a [[1, 2], [2, 3], [4, 5]] print a.reverse() None


???
Thanks...
Jul 18 '05 #1
3 2001
On 2004-09-11, manuel <ma******************@tin.it> wrote:
a = [[1,2],[2,3],[4,5]]
print a [[1, 2], [2, 3], [4, 5]] print a.reverse() None a = [[1,2],[2,3],[4,5]]
print a [[1, 2], [2, 3], [4, 5]] a.reverse()
print a [[4, 5], [2, 3], [1, 2]]

--
Grant Edwards grante Yow! If I felt any more
at SOPHISTICATED I would DIE
visi.com of EMBARRASSMENT!
Jul 18 '05 #2
Grant Edwards wrote:
a.reverse()
print a


oops....THANKS :-)
Jul 18 '05 #3
In article <LR***********************@news3.tin.it>,
manuel <ma******************@tin.it> wrote:
>>> a = [[1,2],[2,3],[4,5]]
>>> print a [[1, 2], [2, 3], [4, 5]] >>> print a.reverse() None >>>


???
Thanks...


The reverse() method of lists reverses the list in-place, and returns
None on purpose. Almost everybody finds this surprising when they
discover it for the first time. Many people (myself included) consider
it a design flaw. But, it is an intentional design decision, not a bug.
Jul 18 '05 #4

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

Similar topics

10
by: clementine | last post by:
Hi, I have an array of arrays in the form of list = ,,] The in-built sort(),list.sort() sorts on the first element, if the first elts are equal then it sorts on the second elt and so on...But...
40
by: Xah Lee | last post by:
is it possible in Python to create a function that maintains a variable value? something like this: globe=0; def myFun(): globe=globe+1 return globe
19
by: RAJASEKHAR KONDABALA | last post by:
Hi, Does anybody know what the fastest way is to "search for a value in a singly-linked list from its tail" as oposed to its head? I am talking about a non-circular singly-linked list, i.e.,...
14
by: Henk | last post by:
Hi Guys, (see actual code below) I wrote a little program that is supposed to read a file (input.txt) into memory (using a stack) and then reverse the file and display it to output. It works,...
5
KevinADC
by: KevinADC | last post by:
Introduction This discussion of the sort function is targeted at beginners to perl coding. More experienced perl coders will find nothing new or useful. Sorting lists or arrays is a very common...
8
by: Andrew Savige | last post by:
I'm learning Python by reading David Beazley's "Python Essential Reference" book and writing a few toy programs. To get a feel for hashes and sorting, I set myself this little problem today (not...
6
by: APEJMAN | last post by:
I know what I'm posting here is wired, but it's been 3 days I'm workin g on these codes, but I have no result I post the code here I dont wanne bother you, but if any one of you have time to...
1
by: Chris Rebert | last post by:
On Thu, Oct 2, 2008 at 8:07 PM, David Di Biase <dave.dibiase@gmail.comwrote: Rather than defining a comparison function here (which is less efficient), you can use the 'key' argument, which...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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.