Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k points)

I've utilized this strategy previously yet can't discover it in any of my codes so here I am on Intellipaat :) What I'm attempting to do is split the input to two( the client is approached to enter two digits isolated/separated by space). How might you consider the first digit a and the second digit b? The code so far doesn't appear to work.

a,b= input(split" "("Please enter two digits separated by space"))

1 Answer

0 votes
by (26.4k points)
edited by

Don't call the function wrongly

>>> "hello world".split()

['hello', 'world']

split cuts a string by a space by default, however, you can change this behavior:

>>> "hello, world".split(',')

['hello', ' world']

In your case:

a,b= input("Please enter two digits separated by space").split()

Want to know more information about Python? Join the Python course fast!

Related questions

0 votes
1 answer
0 votes
1 answer
asked Oct 9, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Oct 3, 2019 in Python by Sammy (47.6k points)
0 votes
2 answers
asked Oct 3, 2019 in Python by Tech4ever (20.3k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...