uppercase

How can I split and give uppercase to a string at the same time?

How can I split and give uppercase to a string at the same time? Question: I have this string, I am fairly new to python and I just need help doing this. def this_sentence(My friend went on a tour) I want the Output to look like this [‘MY’, ‘FRIEND’, ‘WENT’, ‘ON’, ‘A’, ‘TOUR’] Asked By: …

Total answers: 2

Making each alternative word lower and upper case

Making each alternative word lower and upper case Question: Ask for a string from the user and make each alternative word lower and upper case (e.g. the string “I am learning to code” would become “i AM learning TO code”). Using the split and join functions will help you here. I did a similar thing …

Total answers: 3

Uppercase every other word in a string using split/join

Uppercase every other word in a string using split/join Question: I have a string: string = "Hello World" That needs changing to: "hello WORLD" Using only split and join in Python. Any help? string = "Hello World" split_str = string.split() Can’t then work out how to get first word to lowercase second word to uppercase …

Total answers: 4

Python change lowercase to uppercase

Python change lowercase to uppercase Question: I need help with python program. I don’t know how to make python change at least 1 lowercase letter to uppercase. from random import * import random pin="" lenght=random.randrange(8,15) for i in range(lenght): pin=pin+chr(randint(97,122)) print(pin) Asked By: ado || Source Answers: I give it a shot with the little …

Total answers: 4

Index capitalization

Index capitalization Question: I want to create a function that capitalizes a string according to the array that is provided. My current function takes in 2 arguments: the string you want to change and an array which would correspond to the letters you want to change. My function looks like so: def capitalize(s, ind): for …

Total answers: 1

Convert whole dataframe from lower case to upper case with Pandas

Convert whole dataframe from lower case to upper case with Pandas Question: I have a dataframe like the one displayed below: # Create an example dataframe about a fictional army raw_data = {‘regiment’: [‘Nighthawks’, ‘Nighthawks’, ‘Nighthawks’, ‘Nighthawks’], ‘company’: [‘1st’, ‘1st’, ‘2nd’, ‘2nd’], ‘deaths’: [‘kkk’, 52, ’25’, 616], ‘battles’: [5, ’42’, 2, 2], ‘size’: [‘l’, ‘ll’, …

Total answers: 8

Check if all characters of a string are uppercase

Check if all characters of a string are uppercase Question: Say I have a string that can contain different characters: e.g. word = "UPPER£CASe" How would I test the string to see if all the characters are uppercase and no other punctuation, numbers, lowercase letters etc? Asked By: ffgghhffgghh || Source Answers: You could use …

Total answers: 6

Count the uppercase letters in a string with Python

Count the uppercase letters in a string with Python Question: I am trying to figure out how I can count the uppercase letters in a string. I have only been able to count lowercase letters: def n_lower_chars(string): return sum(map(str.islower, string)) Example of what I am trying to accomplish: Type word: HeLLo Capital Letters: 3 When …

Total answers: 8