-2

How do I change the value of a variable to lowercase in Python?

For example, when "I study Python programming at KAIST Center for Gift Education." is the value of this variable, how do i make it "i study python programming at kaist center for gifted education"?

  • nonono not that i want all of them to lowercase – Aiden 1L8L May 23 '21 at 05:18
  • 1
    Please go through the [intro tour](https://stackoverflow.com/tour), the [help center](https://stackoverflow.com/help) and [how to ask a good question](https://stackoverflow.com/help/how-to-ask) to see how this site works and to help you improve your current and future questions, which can help you get better answers. "Show me this basic data manipulation" is off-topic for Stack Overflow. Stack Overflow is not intended to replace existing tutorials and documentation. This is trivial to look up; doing so is *your* job, not a valid question. – Prune May 23 '21 at 05:19
  • Does this answer your question? [How do I lowercase a string in Python?](https://stackoverflow.com/questions/6797984/how-do-i-lowercase-a-string-in-python) – aaronn May 23 '21 at 05:23

2 Answers2

0

I would try using .replace() and .lower()

stringEx = stringEx.lower()

output

i study python programming at kaist center for gift education.
Buddy Bob
  • 5,829
  • 1
  • 13
  • 44
0

Just use the lower function

string.lower()

And here is the official documents.

aaronn
  • 448
  • 1
  • 6
  • 16
  • how do i use that in code? my code is sentence = 'I study Python programming at KAIST Center For Gifted Education.' # Initialise counters: vowels = { 'a': 0, 'e': 0, 'i': 0, 'o': 0, 'u': 0, } # for char in sentence: if char in vowels: vowels[char] += 1 print(vowels['a']) print(vowels['e']) print(vowels['i']) print(vowels['o']) print(vowels['u']) – Aiden 1L8L May 23 '21 at 05:34
  • @Aiden that's another question, but if you need to count occurrence of some characters in the string you can use `count` function. first convert sentence to lower case and then: for char in vowels: vowels[char] = sentence.count(char) – aaronn May 23 '21 at 05:44