How to make python accepts inputs from multiple lines? [duplicate]
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.
python
marked as duplicate by SiHa, Chris_Rands
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.
add a comment |
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.
python
marked as duplicate by SiHa, Chris_Rands
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.
add a comment |
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.
python
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
python
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
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
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.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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)
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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)
add a comment |
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)
add a comment |
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)
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)
answered Nov 21 '18 at 13:00
Filip MłynarskiFilip Młynarski
1,7961413
1,7961413
add a comment |
add a comment |