I want to define a function that takes a multi-line input and outputs, say, the first line. For example, if the input is
13
16 12 11
15 18
then the output would be 13. I’ve been scouring the documentation and various educational websites for hours but can’t find anything. They all seem to assume that all inputs either fit on a single line or are imported from a file. But this seems like something so basic I find it hard to believe that it can’t be done. Any ideas?
Edit: Seems like Reddit chose now to completely break, every time I try to type a comment the box gets covered by the comment below it and I can’t even hit submit. Anyway, a few of you have made similar suggestions, but every time I try one, the code fails to run (I thought compile was a synonym for run, but I guess it isn’t). The error message I get is:
AttributeError: ‘list’ object has no attribute ‘split’
submitted by /u/flagellaVagueness
[link] [comments]
r/learnpython I want to define a function that takes a multi-line input and outputs, say, the first line. For example, if the input is 13 16 12 11 15 18 then the output would be 13. I’ve been scouring the documentation and various educational websites for hours but can’t find anything. They all seem to assume that all inputs either fit on a single line or are imported from a file. But this seems like something so basic I find it hard to believe that it can’t be done. Any ideas? Edit: Seems like Reddit chose now to completely break, every time I try to type a comment the box gets covered by the comment below it and I can’t even hit submit. Anyway, a few of you have made similar suggestions, but every time I try one, the code fails to run (I thought compile was a synonym for run, but I guess it isn’t). The error message I get is: AttributeError: ‘list’ object has no attribute ‘split’ submitted by /u/flagellaVagueness [link] [comments]
I want to define a function that takes a multi-line input and outputs, say, the first line. For example, if the input is
13
16 12 11
15 18
then the output would be 13. I’ve been scouring the documentation and various educational websites for hours but can’t find anything. They all seem to assume that all inputs either fit on a single line or are imported from a file. But this seems like something so basic I find it hard to believe that it can’t be done. Any ideas?
Edit: Seems like Reddit chose now to completely break, every time I try to type a comment the box gets covered by the comment below it and I can’t even hit submit. Anyway, a few of you have made similar suggestions, but every time I try one, the code fails to run (I thought compile was a synonym for run, but I guess it isn’t). The error message I get is:
AttributeError: ‘list’ object has no attribute ‘split’
submitted by /u/flagellaVagueness
[link] [comments]