String vs. Char | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

String vs. Char

I have programmed in C++ and strings always use double quotes while char uses single quotes. How do you differentiate char and strings in python if a string can use double or single quotes?

21st Apr 2019, 10:58 PM
Heather
2 Answers
+ 6
Python does not have what you called a character. Instead, even 1-letter texts are also strings. When you try to slice up a string into 1-letter bits you still get strings.
21st Apr 2019, 11:35 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
There is no char data type in Python. A 'character' is just a string of length 1.
21st Apr 2019, 11:36 PM
Hatsy Rei
Hatsy Rei - avatar