I'm trying to resolve an exercise in python. It has an platform with some pre-code part and I have to enter some code to complete. But usually, I like to try the code in VS Code as well, to understand a little more about the problem. In this case, the resolution was easy, but I couldn't understad the pre-coded part, in order to replicate.
import sys
import xml.etree.ElementTree as etree
def get_attr_number(node):
\# your code goes here
return root
if __name__ == '__main__':
sys.stdin.readline()
xml = sys.stdin.read()
tree = etree.ElementTree(etree.fromstring(xml))
root = tree.getroot()
print(get_attr_number(root))
In particular, I couldn't understand the stdin part. Usually i use it for read document, previously opened. How does it read the xml data from the input? This part is blocked, and works in the platform. How can I replicate this process, providing data. The input should be some xml code.
How can I input data from the terminal (Power Shell or terminal from VS Code) so it can process my data and I can execute the def function?