python help on strings?

2009-02-08 12:04 am
I did teh following and i need to have string 3= upper case for all vowel and lower case for all consonants. how can i do that?

String1= "My name is "
String2= "Jennifer"
String3= String1+ String2
print String3

回答 (2)

2009-02-10 11:38 am
✔ 最佳答案
Here you go:

>>> String3.lower().replace('a', 'A').replace('e', 'E').replace('o', 'O').replace('i', 'I').replace('u', 'U')
'my nAmE Is jEnIfEr'
2009-02-08 8:15 am
The command for upper case letters is .upper()

It should look something like this:

string1 = "My name is "
string2 = "Jennifer"
string3 = string1+string2
vowels = aeiou
if vowels in string1
print string3.upper()

I know this does not work, and I didnt test it to find out where the error is, but thats the basic idea. Python 2.6

Good luck


收錄日期: 2021-04-25 13:51:39
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20090207160445AAR7aLB

檢視 Wayback Machine 備份