I am trying to make a string alternate between upper and lower case letters. My current code is this:
def skyline (str1): result = '' index = 0 for i in str1: result += str1[index].upper() + str1[index + 1].lower() index += 2 return result
When I run the above code I get an error saying
String index out of range. How can I fix this?
How to sort a string in C alphabetically with upper case letters before equivalent lower case letters.
input: baBadxDoutput: aaBbDdx
I have the following code to check if the value of certain column contains the given string:
However, when I tried to make it work for all letter cases like:
I got the following error:
AttributeError: 'function' object has no attribute 'contains'
What should be the correct way to call the lower() function, so I can make sure the match is case insensitive? Thanks!
This question already has an answer here:
I have a string like this LUXOR and I want to convert other letters to lowercase except first letter or the string.that meant, I want this string Luxor from above string. I can convert full string to upper or lower by using
ToLower.but how can I do this.hope your help with this.thank you
Let's say I have a string
x="1. this should be capitalized"
Right now if I want to check if the first letter is capitalized
s = "1. (t)his should be capitalized"s2 = match(r"^.*?([a-zA-Z])", s).captures@show all(islowercase, s2)# true
If I do
islowercase(s2) I get a
MethodError. Though I could also do
@show uppercasefirst(s2) != s2 but this seems unnecessarily verbose.