Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8923935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:15:48+00:00 2026-06-15T07:15:48+00:00

I am trying out this problem in a coding competition. I believe I have

  • 0

I am trying out this problem in a coding competition. I believe I have solved the problem, but have some problem in taking the input. Help me out here:


Input

The first line of the input contains a single integer T denoting the number of test cases. The description for T test cases follows. Each test case consists of a single line containing two space-separated strings R and S denoting the two recipes.


Now, I have coded the problem and it seems to work, but whenever I directly copy paste the input values, it fails to work by giving this error message


T= int(raw_input())
ValueError: invalid literal for int() with base 10:
'3\nalex axle\nparadise diapers\nalice bob'

Whenever I try to submit the problem, I get an error message. May be they are also copy pasting the input values and checking for the output. My code skeleton goes something like this


def whetherGranama(str1,str2):
    return "NO"
    #can't give the implementation out yet

T= int(raw_input())
ans=[]
for x in range(0,T):
    s=raw_input()
    s1,s2=s.split()
    ans.append(whetherGranama(s1,s2))

for elem in ans:
    print elem

How can I fix the \n error ? I think the entire input is treated as one string.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:15:50+00:00Added an answer on June 15, 2026 at 7:15 am

    If the entire input is being read in as one string, you could try using stdin.readline() instead of raw_input to capture the input stream:

    from sys import stdin
    T = int(stdin.readline())
    

    Since this is a coding competition however, I’m assuming that speed is of the essence. Since IO operations are computationally expensive, you should actually welcome the opportunity to read all of your input at one time. In other words, it’s generally faster to read it in all at once and then parse the input within your code. I guess in your case, it would look something like this (assuming that it comes in all at once by design):

    data = raw_input().splitlines() 
    #(or data = sys.stdin.read().splitlines() or data = list(sys.stdin.readlines()))
    
    T = int(data[0])
    S = (s.split() for s in data[1:])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So we have this problem that we are trying to figure out. Heres what
I have been trying to figure out why I am getting this problem and
I've been pulling out my hair trying to figure this problem out. I have
I need some help with some CSS coding. I have been trying to get
So I'm trying out this new TDD thing (about time haha). Anyways I have
I have a coding/maths problem that I need help translating into C#. It's a
I've been trying to figure this out all night, but I guess my knowledge
Coding in VB.Net Hi guys I've got this problem where I'm trying to assign
Boost Network I am trying out this code in a small console app on
I am learning LINQ and was trying out this example related to select clause.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.