Skip to content

How do i input multiple strings or numbers seperately? #21407

Answered by mpboom
42sungwook asked this question in General
Discussion options

You must be logged in to vote

Hi @WookGyeo and welcome to the forum!

Here’s your code formatted in a code block for readability:

# answer you want
a, b = input().split()
c = a + b
print(c)

does not give answer, only prints out a

a = input()
b = input()
c = a + b
print(c)

It can help to be a bit more explicit about what you actually want. Since I don’t know what your goal is, it’s hard to help you out. I can explain what the code does in both cases, so you’re hopefully able to determine for yourself what is going wrong.

  • The first piece of code takes input from the command line, and uses split() to split up the input string. You can provide an argument to split to tell Python where to split the string on, but if you d…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants