Try reading this- https://www.geeksforgeeks.org/python-input-methods-competitive-programming/ Also format your code.