Question about the underscore need to clarify | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Question about the underscore need to clarify

How come i need an underscore if i were to write roll_again="yes"

1st Jan 2017, 11:48 PM
brown
4 Antworten
+ 1
python doesn't like spaces in variable names/class names/function names. You can either use underscores as replacements, or make the name all one word, separating words with capitals such as: spillMilk or RollAgain
2nd Jan 2017, 12:37 AM
Kaleb Cole-Wood
Kaleb Cole-Wood - avatar
0
You can name your variable the way you like, as long as it is (somehow) consistent within your code. You can name if rollAgain, if you want. It is just a convention to write variables with an underscore between words in Python
2nd Jan 2017, 12:09 AM
Amaras A
Amaras A - avatar
0
Thanks for clearing that up for me ! Im new to this stuff but i love learning it
2nd Jan 2017, 3:35 AM
brown
0
Thanks for clearing that up for me ! Im new to this stuff but i love learning it
2nd Jan 2017, 3:35 AM
brown