-4

I am asking the user to input some ID numbers, but they will only be able to paste them into the program horizontally.

print("Please cut and paste your ID numbers:")

User input:
12345
54321
99999

I want python to perform this function on all the numbers:

print ('s'+(user input)+'@'+'students.xisd.org')

This is the output that I want:

s12345@student.xisd.org
s54321@student.xisd.org
s99999@student.xisd.org

I don't know how to allow python to accept several lines of horizontal input and give the same outputs.

  • Does this answer your question - [Taking multi line input](https://stackoverflow.com/a/30239138/10145519). And also take care of what prune said. – P S Solanki Sep 04 '20 at 05:18
  • Please repeat [on topic](https://stackoverflow.com/help/on-topic) and [how to ask](https://stackoverflow.com/help/how-to-ask) from the [intro tour](https://stackoverflow.com/tour). You have to make an honest attempt at the solution, and then ask a *specific* question about your implementation. Reading input from a line is well-documented in many tutorials; we expect you to work through those before posting here. – Prune Sep 04 '20 at 05:20
  • Please see [How to Ask a Homework Question](https://meta.stackoverflow.com/questions/334822/how-do-i-ask-and-answer-homework-questions). Simply dumping your assignment here is not acceptable. – Prune Sep 04 '20 at 05:20
  • Yes. Anywhere from 12 to 20 seven digit numbers. – Johnny Alcano Sep 04 '20 at 05:21
  • `print (f"s{input()}@students.xisd.org")` – deadshot Sep 04 '20 at 05:22
  • @anuragal That's just a mistake from OP. If a user pastes the numbers horizontally, the example input by OP should have been space separated not '\n' separated. – P S Solanki Sep 04 '20 at 05:27

2 Answers2

1

When a newline character is to be included as part of the string, it can no longer serve the purpose of signaling the end of input. You could try the following:

import sys
multiline_str = sys.stdin.read()

Enter ctrl+z on a blank line to signal the end of input.

gCo
  • 11
  • 4
1

This should work for you. You will have to press enter twice to indicate the end of the input (precisely to break out of while loop).

numbers = []

while True:
    num = input()
    if num:
        numbers.append(num)
    else:
        break
    
for num in numbers:
    print('s' + num + '@students.xisd.org')
P S Solanki
  • 1,033
  • 2
  • 11
  • 26