0

Hello All,

I am new in this language and want to access the run time value

In other words, I want make a program in which ask the value from

User like scanf() function in C and cin>> function in Cpp

So is there any function or method by which user can enter value and print on screen

I have made program in which value is define early

>>>l=10
>>>print("Entered  Value is ",l)
>>>Entered Value is 10

Now i want user can enter value at run time and get put

thnanX in advance

7
Contributors
8
Replies
18
Views
7 Years
Discussion Span
Last Post by Reverend Jim
0

this function is not working on my comand line terminal !

Is this what you are looking for?

>>> a= raw_input()
10
>>> print a
10
>>>
0

Look like you use python 3

>>> #Python3 has only input that return a string
>>> user_input = input('Give me a number: ')
Give me a number: 10
>>> user_input
'10'
>>> type(user_input)
<class 'str'>
>>> print 'Your number was %s' % (user_input)
SyntaxError: invalid syntax (<pyshell#4>, line 1)
>>> print ('Your number was %s' % (user_input))
Your number was 10
>>> #And print has become function print()
>>>
0

its works

thank you so much !

Look like you use python 3

>>> #Python3 has only input that return a string
>>> user_input = input('Give me a number: ')
Give me a number: 10
>>> user_input
'10'
>>> type(user_input)
<class 'str'>
>>> print 'Your number was %s' % (user_input)
SyntaxError: invalid syntax (<pyshell#4>, line 1)
>>> print ('Your number was %s' % (user_input))
Your number was 10
>>> #And print has become function print()
>>>
1

You google "python convert string to integer" and pick one of the 536,000 results instead of asking someone here to do it for you.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.