Getting “None” instead of list of values in python [duplicate]












0
















This question already has an answer here:




  • list.reverse does not return list?

    8 answers




I am currently working on POC on Alibaba Cloud and not authorized to share the information. I am a beginner in python. Let me consider an example to address my issue.



I am getting none instead of list of values,



Example code:



NumSet={1,2,3,4,5,6,7,8,9,10}
NumList = list(NumSet).reverse()
print(NumList)


Output:



None



What I am missing?










share|improve this question













marked as duplicate by juanpa.arrivillaga python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 30 '18 at 14:42


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 2





    the .reverse() method doesn't return anything, it directly change the list.

    – iElden
    Dec 30 '18 at 14:41






  • 1





    The most pythonic way to reverse a list is NumList[::-1]. You don't need any reverse or other routines

    – Bazingaa
    Dec 30 '18 at 14:43


















0
















This question already has an answer here:




  • list.reverse does not return list?

    8 answers




I am currently working on POC on Alibaba Cloud and not authorized to share the information. I am a beginner in python. Let me consider an example to address my issue.



I am getting none instead of list of values,



Example code:



NumSet={1,2,3,4,5,6,7,8,9,10}
NumList = list(NumSet).reverse()
print(NumList)


Output:



None



What I am missing?










share|improve this question













marked as duplicate by juanpa.arrivillaga python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 30 '18 at 14:42


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 2





    the .reverse() method doesn't return anything, it directly change the list.

    – iElden
    Dec 30 '18 at 14:41






  • 1





    The most pythonic way to reverse a list is NumList[::-1]. You don't need any reverse or other routines

    – Bazingaa
    Dec 30 '18 at 14:43
















0












0








0


1







This question already has an answer here:




  • list.reverse does not return list?

    8 answers




I am currently working on POC on Alibaba Cloud and not authorized to share the information. I am a beginner in python. Let me consider an example to address my issue.



I am getting none instead of list of values,



Example code:



NumSet={1,2,3,4,5,6,7,8,9,10}
NumList = list(NumSet).reverse()
print(NumList)


Output:



None



What I am missing?










share|improve this question















This question already has an answer here:




  • list.reverse does not return list?

    8 answers




I am currently working on POC on Alibaba Cloud and not authorized to share the information. I am a beginner in python. Let me consider an example to address my issue.



I am getting none instead of list of values,



Example code:



NumSet={1,2,3,4,5,6,7,8,9,10}
NumList = list(NumSet).reverse()
print(NumList)


Output:



None



What I am missing?





This question already has an answer here:




  • list.reverse does not return list?

    8 answers








python python-3.x alibaba-cloud






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 30 '18 at 14:39









Ranjith UdayakumarRanjith Udayakumar

204




204




marked as duplicate by juanpa.arrivillaga python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 30 '18 at 14:42


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by juanpa.arrivillaga python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 30 '18 at 14:42


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2





    the .reverse() method doesn't return anything, it directly change the list.

    – iElden
    Dec 30 '18 at 14:41






  • 1





    The most pythonic way to reverse a list is NumList[::-1]. You don't need any reverse or other routines

    – Bazingaa
    Dec 30 '18 at 14:43
















  • 2





    the .reverse() method doesn't return anything, it directly change the list.

    – iElden
    Dec 30 '18 at 14:41






  • 1





    The most pythonic way to reverse a list is NumList[::-1]. You don't need any reverse or other routines

    – Bazingaa
    Dec 30 '18 at 14:43










2




2





the .reverse() method doesn't return anything, it directly change the list.

– iElden
Dec 30 '18 at 14:41





the .reverse() method doesn't return anything, it directly change the list.

– iElden
Dec 30 '18 at 14:41




1




1





The most pythonic way to reverse a list is NumList[::-1]. You don't need any reverse or other routines

– Bazingaa
Dec 30 '18 at 14:43







The most pythonic way to reverse a list is NumList[::-1]. You don't need any reverse or other routines

– Bazingaa
Dec 30 '18 at 14:43














2 Answers
2






active

oldest

votes


















3














list.reverse() reverses the list in-place and returns nothing (or returns None).



NumList = list(NumSet)  # convert to list first
NumList.reverse() # reverse in-place


This is the correct way to do it.






share|improve this answer
























  • It should also be noted that if you need not-in-place reversal, you can iterate over reversed(list(NumSet)).

    – AKX
    Dec 30 '18 at 14:43













  • @AKX What does set() in your code do?

    – iBug
    Dec 30 '18 at 14:43











  • Derp, I had misread the set-to-list conversion as being the other way around. Fixed.

    – AKX
    Dec 30 '18 at 14:46



















0














list.reverse() doesn't return the list reversed. What it does is reversing the list in-place. Just change to this and it ill work



NumSet = {1,2,3,4,5,6,7,8,9,10}
NumList = list(NumSet)
NumList.reverse()
print(NumList)





share|improve this answer






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    list.reverse() reverses the list in-place and returns nothing (or returns None).



    NumList = list(NumSet)  # convert to list first
    NumList.reverse() # reverse in-place


    This is the correct way to do it.






    share|improve this answer
























    • It should also be noted that if you need not-in-place reversal, you can iterate over reversed(list(NumSet)).

      – AKX
      Dec 30 '18 at 14:43













    • @AKX What does set() in your code do?

      – iBug
      Dec 30 '18 at 14:43











    • Derp, I had misread the set-to-list conversion as being the other way around. Fixed.

      – AKX
      Dec 30 '18 at 14:46
















    3














    list.reverse() reverses the list in-place and returns nothing (or returns None).



    NumList = list(NumSet)  # convert to list first
    NumList.reverse() # reverse in-place


    This is the correct way to do it.






    share|improve this answer
























    • It should also be noted that if you need not-in-place reversal, you can iterate over reversed(list(NumSet)).

      – AKX
      Dec 30 '18 at 14:43













    • @AKX What does set() in your code do?

      – iBug
      Dec 30 '18 at 14:43











    • Derp, I had misread the set-to-list conversion as being the other way around. Fixed.

      – AKX
      Dec 30 '18 at 14:46














    3












    3








    3







    list.reverse() reverses the list in-place and returns nothing (or returns None).



    NumList = list(NumSet)  # convert to list first
    NumList.reverse() # reverse in-place


    This is the correct way to do it.






    share|improve this answer













    list.reverse() reverses the list in-place and returns nothing (or returns None).



    NumList = list(NumSet)  # convert to list first
    NumList.reverse() # reverse in-place


    This is the correct way to do it.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 30 '18 at 14:41









    iBugiBug

    20.4k63864




    20.4k63864













    • It should also be noted that if you need not-in-place reversal, you can iterate over reversed(list(NumSet)).

      – AKX
      Dec 30 '18 at 14:43













    • @AKX What does set() in your code do?

      – iBug
      Dec 30 '18 at 14:43











    • Derp, I had misread the set-to-list conversion as being the other way around. Fixed.

      – AKX
      Dec 30 '18 at 14:46



















    • It should also be noted that if you need not-in-place reversal, you can iterate over reversed(list(NumSet)).

      – AKX
      Dec 30 '18 at 14:43













    • @AKX What does set() in your code do?

      – iBug
      Dec 30 '18 at 14:43











    • Derp, I had misread the set-to-list conversion as being the other way around. Fixed.

      – AKX
      Dec 30 '18 at 14:46

















    It should also be noted that if you need not-in-place reversal, you can iterate over reversed(list(NumSet)).

    – AKX
    Dec 30 '18 at 14:43







    It should also be noted that if you need not-in-place reversal, you can iterate over reversed(list(NumSet)).

    – AKX
    Dec 30 '18 at 14:43















    @AKX What does set() in your code do?

    – iBug
    Dec 30 '18 at 14:43





    @AKX What does set() in your code do?

    – iBug
    Dec 30 '18 at 14:43













    Derp, I had misread the set-to-list conversion as being the other way around. Fixed.

    – AKX
    Dec 30 '18 at 14:46





    Derp, I had misread the set-to-list conversion as being the other way around. Fixed.

    – AKX
    Dec 30 '18 at 14:46













    0














    list.reverse() doesn't return the list reversed. What it does is reversing the list in-place. Just change to this and it ill work



    NumSet = {1,2,3,4,5,6,7,8,9,10}
    NumList = list(NumSet)
    NumList.reverse()
    print(NumList)





    share|improve this answer




























      0














      list.reverse() doesn't return the list reversed. What it does is reversing the list in-place. Just change to this and it ill work



      NumSet = {1,2,3,4,5,6,7,8,9,10}
      NumList = list(NumSet)
      NumList.reverse()
      print(NumList)





      share|improve this answer


























        0












        0








        0







        list.reverse() doesn't return the list reversed. What it does is reversing the list in-place. Just change to this and it ill work



        NumSet = {1,2,3,4,5,6,7,8,9,10}
        NumList = list(NumSet)
        NumList.reverse()
        print(NumList)





        share|improve this answer













        list.reverse() doesn't return the list reversed. What it does is reversing the list in-place. Just change to this and it ill work



        NumSet = {1,2,3,4,5,6,7,8,9,10}
        NumList = list(NumSet)
        NumList.reverse()
        print(NumList)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 30 '18 at 14:46









        BiriveraBirivera

        75




        75















            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas