How to make python accepts inputs from multiple lines? [duplicate]












-1
















This question already has an answer here:




  • How do I read multiple lines of raw input in Python?

    7 answers




I want to ask the user for a message and then to store it to a variable x.



So



x = input("Insert a message")


but then I want the program to allow the user to write on the next line. The program should then store each line as a separate message.



Is there a way to make python create an infinite number of variables as necessary.



or do I have to put the messages into a string then strip it into a list.










share|improve this question















marked as duplicate by SiHa, Chris_Rands 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();
}
);
});
});
Nov 21 '18 at 13:05


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.























    -1
















    This question already has an answer here:




    • How do I read multiple lines of raw input in Python?

      7 answers




    I want to ask the user for a message and then to store it to a variable x.



    So



    x = input("Insert a message")


    but then I want the program to allow the user to write on the next line. The program should then store each line as a separate message.



    Is there a way to make python create an infinite number of variables as necessary.



    or do I have to put the messages into a string then strip it into a list.










    share|improve this question















    marked as duplicate by SiHa, Chris_Rands 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();
    }
    );
    });
    });
    Nov 21 '18 at 13:05


    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.





















      -1












      -1








      -1


      0







      This question already has an answer here:




      • How do I read multiple lines of raw input in Python?

        7 answers




      I want to ask the user for a message and then to store it to a variable x.



      So



      x = input("Insert a message")


      but then I want the program to allow the user to write on the next line. The program should then store each line as a separate message.



      Is there a way to make python create an infinite number of variables as necessary.



      or do I have to put the messages into a string then strip it into a list.










      share|improve this question

















      This question already has an answer here:




      • How do I read multiple lines of raw input in Python?

        7 answers




      I want to ask the user for a message and then to store it to a variable x.



      So



      x = input("Insert a message")


      but then I want the program to allow the user to write on the next line. The program should then store each line as a separate message.



      Is there a way to make python create an infinite number of variables as necessary.



      or do I have to put the messages into a string then strip it into a list.





      This question already has an answer here:




      • How do I read multiple lines of raw input in Python?

        7 answers








      python






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 12:58









      Ali AzG

      7131616




      7131616










      asked Nov 21 '18 at 12:58









      user154844user154844

      11




      11




      marked as duplicate by SiHa, Chris_Rands 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();
      }
      );
      });
      });
      Nov 21 '18 at 13:05


      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 SiHa, Chris_Rands 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();
      }
      );
      });
      });
      Nov 21 '18 at 13:05


      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.


























          1 Answer
          1






          active

          oldest

          votes


















          1














          You could create list to store all messages and then keep asking user for input in while loop until they let's say type "quit"



          messages = 
          while True:
          new_message = input('Insert a message: ')
          if new_message == 'quit':
          break

          messages.append(new_message)

          print(messages)





          share|improve this answer






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            You could create list to store all messages and then keep asking user for input in while loop until they let's say type "quit"



            messages = 
            while True:
            new_message = input('Insert a message: ')
            if new_message == 'quit':
            break

            messages.append(new_message)

            print(messages)





            share|improve this answer




























              1














              You could create list to store all messages and then keep asking user for input in while loop until they let's say type "quit"



              messages = 
              while True:
              new_message = input('Insert a message: ')
              if new_message == 'quit':
              break

              messages.append(new_message)

              print(messages)





              share|improve this answer


























                1












                1








                1







                You could create list to store all messages and then keep asking user for input in while loop until they let's say type "quit"



                messages = 
                while True:
                new_message = input('Insert a message: ')
                if new_message == 'quit':
                break

                messages.append(new_message)

                print(messages)





                share|improve this answer













                You could create list to store all messages and then keep asking user for input in while loop until they let's say type "quit"



                messages = 
                while True:
                new_message = input('Insert a message: ')
                if new_message == 'quit':
                break

                messages.append(new_message)

                print(messages)






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 21 '18 at 13:00









                Filip MłynarskiFilip Młynarski

                1,7961413




                1,7961413

















                    這個網誌中的熱門文章

                    Tangent Lines Diagram Along Smooth Curve

                    Yusuf al-Mu'taman ibn Hud

                    Zucchini