You are not logged in. Please login at www.codechef.com to post your questions!

×

getting nzec in k fib solving in python

can someone point out mistake in my solution here is the link to solution:-https://www.codechef.com/viewsolution/17201354

asked 31 Jan, 03:01

bhpra's gravatar image

2★bhpra
1036
accept rate: 12%

as far as i am able to find it has something to do with input because this (https://www.codechef.com/viewsolution/17201888)solution of mine got AC :) but can someone explain me what was wrong in my code before. As far as i understand input() is taking a string so it take is take n and k both at the same time, is it possible to take input sequentially like as we do in c++ cin>>n cin>>k correct me if i am wrong i am new to python please share some resources for getting started with python that would be very awesome

(31 Jan, 10:53) bhpra2★

Yeah you can do it like that n,k = [int (x) for x in input ().split ()]

link

answered 31 Jan, 12:57

chhekur's gravatar image

1★chhekur
233
accept rate: 0%

could you explain this syntax @chhekur

(31 Jan, 13:22) bhpra2★
1

This is called List Comprehension. In it this is just taking input as string but it splitting values by space and assign to variables, Here I used two variable because, I have to take two values in different variable. But if you use a single variable like this N = [int(x) for x in input().split()] it will create a list of all values and assign to N.

(31 Jan, 13:46) chhekur1★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×387
×190
×4

question asked: 31 Jan, 03:01

question was seen: 136 times

last updated: 31 Jan, 13:47