Asked  6 Months ago    Answers:  5   Viewed   40 times

I want to create a Python program which takes in multiple lines of user input. For example:

This is a multilined input.
It has multiple sentences.
Each sentence is on a newline.

How can I take in multiple lines of raw input?


sentinel = '' # ends when this string is seen
for line in iter(raw_input, sentinel):
    pass # do things here

To get every line as a string you can do:

'n'.join(iter(raw_input, sentinel))

Python 3:

'n'.join(iter(input, sentinel))
Tuesday, June 1, 2021
answered 6 Months ago

The following works for Python 3:

from PIL import Image
import requests

im =, stream=True).raw)


Tuesday, June 1, 2021
answered 6 Months ago

You can use xlrd.

From its documentation, you can read that dates are always stored as numbers; however, you can use xldate_as_tuple to convert it to a python date.

Note: the version on the PyPI seems more up-to-date than the one available on xlrd's website.

Tuesday, June 8, 2021
answered 6 Months ago

You can use str.isdigit and str.isalpha:

if a.isalpha():
   #do something
elif a.isdigit():
   #do something

help on str.isdigit:

>>> print str.isdigit.__doc__
S.isdigit() -> bool

Return True if all characters in S are digits
and there is at least one character in S, False otherwise.

help on str.isalpha:

>>> print str.isalpha.__doc__
S.isalpha() -> bool

Return True if all characters in S are alphabetic
and there is at least one character in S, False otherwise.
Thursday, July 29, 2021
answered 4 Months ago

You need to use

return getNum(numList)

instead of


in the getNum function. The reason is that you call the getNum function recursively, thus you have to return the accepted value back through all recursions you made. Additionally, you must pass the arguments to each call.

Saturday, August 7, 2021
answered 4 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :