+ 10

Python variables [SOLVED]

Is it possible to assign an integer as a string variable? For example: 1 = “Hello World”

14th May 2020, 7:35 PM
Zach Janzen
85 Antworten
+ 45
No, a variable name is not allowed to start with a number. There are more rules: a variable name must start with a letter or an underscore, can only contain [ A-z 0-9 _ ] and is case sensitive
14th May 2020, 7:37 PM
DeX97
+ 13
Granger A variable can also start with an underscore (_) instead of text. As an example: _1 = 1 is perfectly valid
15th May 2020, 4:54 PM
DeX97
+ 6
Thank you.
14th May 2020, 7:39 PM
Zach Janzen
+ 6
No bro, in Python only Name of variable with letters, number but not at start, and you can use _
19th Apr 2021, 12:28 AM
NICOLAY CORRALES VARGAS
NICOLAY CORRALES VARGAS - avatar
+ 4
vars = ["1","2"',"3"] vars[1]=2
14th May 2020, 8:10 PM
Oma Falk
Oma Falk - avatar
+ 3
No you can't assing a variable as an integer
15th May 2020, 6:33 AM
Raza Alam
Raza Alam - avatar
+ 3
no but maybe eggs = 6 will do
11th Jul 2021, 10:48 AM
Ram Mangulabnan
Ram Mangulabnan - avatar
+ 3
Zach Janzen There are some rules to follow while writing a variable name. A variable name must start with a letter or the underscore character. It cannot start with a number. It can only have alpha-numeric characters and underscores. These are case-sensitive (age, Age and AGE are three different variables).
5th Oct 2021, 12:33 PM
Pythonist
Pythonist - avatar
+ 2
No , There are certain rules to declare a variable in any programming language. *The variables should not start with numeric values. *The variables should contain only alphabets, and numbers and underscore. *The variables should contains spaces , hyphens etc. *The variable name should not be same as a keyword in that language.
2nd Nov 2021, 4:38 PM
Nalluri Sai Kiran
Nalluri Sai Kiran - avatar
+ 2
In your variable name, make sure that it represents your code. To make it readable.
12th Nov 2021, 6:58 AM
Appiah Kumah Miracle
Appiah Kumah Miracle - avatar
+ 2
No, a variable name is not allowed to start with a number. There are more rules: a variable name must start with a letter or an underscore, can only contain [ A-z 0-9 _ ] and is case sensitive We can do like this 👇👇👇 _1="Kiibo" Ok
20th Sep 2022, 3:23 PM
Anmol Tyagi
Anmol Tyagi - avatar
+ 1
Kiibo Ghayal, thats an interesting way.
14th May 2020, 7:54 PM
Zach Janzen
14th May 2020, 8:16 PM
Oma Falk
Oma Falk - avatar
14th May 2020, 11:03 PM
SpaghettDev
SpaghettDev - avatar
+ 1
No, it's a rule that we can't use an integer in the first letter of a variable. if you try to assign an variable like '1 = "Hello world"', it will throw an error.
15th May 2020, 3:10 AM
Rellot's screwdriver
Rellot's screwdriver - avatar
+ 1
No,variable name cannot start with integer.
15th May 2020, 11:14 AM
salman haider
salman haider - avatar
+ 1
It is not possible, you can't start your variable with with numbers..
15th May 2020, 11:46 PM
Eke John Igwe
Eke John Igwe - avatar
+ 1
No you can not use number for naming variables. Rules for Python variables: A variable name must start with a letter or the underscore character. A variable name cannot start with a number. A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _)
6th Apr 2021, 6:34 AM
ADITYA KUMAR
+ 1
No, because variable doesn't allow to start with any number. Like, 1_variable_name ×
12th Apr 2021, 1:52 PM
°Aπ$hu°
°Aπ$hu° - avatar
+ 1
no, variables can never start by a number
26th Apr 2021, 7:51 PM
Dayron Alexis Díaz Rodríguez
Dayron Alexis Díaz Rodríguez - avatar