Basic Input/Output
Read a line of input as a string
s = input()
Katta: Echo echo
Read a string, either “Hello” or “Hallo”, and repeat it twice.
- Intended solution:
Use a variable to store input: .. literalinclude:: ../../problems/echoecho/submissions/accepted/th.py
- lines:
3-
- Other solutions:
Since there are only two possible inputs, we can be less general, avoiding the variable but using selection:
if input() == "Hello": print("Hello") print("Hello") else: print("Hallo") print("Hallo")
- Wrong ideas:
a = input() print(a)
a = input() print(a) a = input() print(a)
Note
Output validation is lenient with respect to whitespace and letter case.