How to assign input value to a variable in python? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

How to assign input value to a variable in python?

I am just a beginner to python ! I wanna know what function can be used to create such a program that asks to input certain value and then stores the value in a variable.

10th Apr 2020, 9:24 PM
Sheshadri S.B
Sheshadri S.B - avatar
3 ответов
+ 3
For string: n=input( ) For integer number: n= int( input( ) ) You can check this lesson: https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2426/
10th Apr 2020, 9:30 PM
Cmurio
Cmurio - avatar
0
n =input()# stores input in n
10th Apr 2020, 9:27 PM
Justus
Justus - avatar
0
You can use input() function. Let's say you're making a variable which is n, and you want to have an input to the variable you have just make. # This will ask the input and put it to the n variabel n = input() You also can put some question on the input by doing this : n = input("How are you? ") The input that you give in input() will stores the value type(str) to the variable. In case you want to have type(int) value, you can use : n = int(input())
10th Apr 2020, 11:29 PM
Davin
Davin - avatar