Using list comprehensions, transform all vowels within a string to upper case? [duplicate]
This question already has an answer here:
python how to uppercase some characters in string
7 answers
Thanks for your help
Example byron = bYrOn
This is an old homework I'm looking over.
python list-comprehension
marked as duplicate by eyllanesc
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 19:49
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
python how to uppercase some characters in string
7 answers
Thanks for your help
Example byron = bYrOn
This is an old homework I'm looking over.
python list-comprehension
marked as duplicate by eyllanesc
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 19:49
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
"".join([letter.upper() if letter in "aeiouy" else letter for letter in string])
?
– L3viathan
Nov 22 '18 at 19:48
Alternative, without comprehensions:string.translate({97:65, 101:69, 105:73, 111:79, 117:85, 121:89})
– L3viathan
Nov 22 '18 at 19:54
add a comment |
This question already has an answer here:
python how to uppercase some characters in string
7 answers
Thanks for your help
Example byron = bYrOn
This is an old homework I'm looking over.
python list-comprehension
This question already has an answer here:
python how to uppercase some characters in string
7 answers
Thanks for your help
Example byron = bYrOn
This is an old homework I'm looking over.
This question already has an answer here:
python how to uppercase some characters in string
7 answers
python list-comprehension
python list-comprehension
edited Nov 22 '18 at 19:47
eyllanesc
77.4k103156
77.4k103156
asked Nov 22 '18 at 19:47
A J EA J E
335
335
marked as duplicate by eyllanesc
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 19:49
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by eyllanesc
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 19:49
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
"".join([letter.upper() if letter in "aeiouy" else letter for letter in string])
?
– L3viathan
Nov 22 '18 at 19:48
Alternative, without comprehensions:string.translate({97:65, 101:69, 105:73, 111:79, 117:85, 121:89})
– L3viathan
Nov 22 '18 at 19:54
add a comment |
2
"".join([letter.upper() if letter in "aeiouy" else letter for letter in string])
?
– L3viathan
Nov 22 '18 at 19:48
Alternative, without comprehensions:string.translate({97:65, 101:69, 105:73, 111:79, 117:85, 121:89})
– L3viathan
Nov 22 '18 at 19:54
2
2
"".join([letter.upper() if letter in "aeiouy" else letter for letter in string])
?– L3viathan
Nov 22 '18 at 19:48
"".join([letter.upper() if letter in "aeiouy" else letter for letter in string])
?– L3viathan
Nov 22 '18 at 19:48
Alternative, without comprehensions:
string.translate({97:65, 101:69, 105:73, 111:79, 117:85, 121:89})
– L3viathan
Nov 22 '18 at 19:54
Alternative, without comprehensions:
string.translate({97:65, 101:69, 105:73, 111:79, 117:85, 121:89})
– L3viathan
Nov 22 '18 at 19:54
add a comment |
1 Answer
1
active
oldest
votes
It is actually preety simple to turn all letters in a string to upper case!
just use the variable name and follow .upper() at the end e.g.
byron="byron"
byron=byron.upper()
however, because you want to give only certain letters the "uppercase" status, you'd want to first assign all vowels:
vowels = set(['a','e','i','o','u'])
then use some python logic to do the rest:
for char in byron:
if char in vowels:
Word = Word.replace(char,(char.upper()))
print (Word)
if you want to be quick just copy the code below as it is the complete code used to do your task:
x="byron"
vowels = set(['a','e','i','o','u'])
Word=x
for char in Word:
if char in vowels:
Word = Word.replace(char,(char.upper()))
print(Word)
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It is actually preety simple to turn all letters in a string to upper case!
just use the variable name and follow .upper() at the end e.g.
byron="byron"
byron=byron.upper()
however, because you want to give only certain letters the "uppercase" status, you'd want to first assign all vowels:
vowels = set(['a','e','i','o','u'])
then use some python logic to do the rest:
for char in byron:
if char in vowels:
Word = Word.replace(char,(char.upper()))
print (Word)
if you want to be quick just copy the code below as it is the complete code used to do your task:
x="byron"
vowels = set(['a','e','i','o','u'])
Word=x
for char in Word:
if char in vowels:
Word = Word.replace(char,(char.upper()))
print(Word)
add a comment |
It is actually preety simple to turn all letters in a string to upper case!
just use the variable name and follow .upper() at the end e.g.
byron="byron"
byron=byron.upper()
however, because you want to give only certain letters the "uppercase" status, you'd want to first assign all vowels:
vowels = set(['a','e','i','o','u'])
then use some python logic to do the rest:
for char in byron:
if char in vowels:
Word = Word.replace(char,(char.upper()))
print (Word)
if you want to be quick just copy the code below as it is the complete code used to do your task:
x="byron"
vowels = set(['a','e','i','o','u'])
Word=x
for char in Word:
if char in vowels:
Word = Word.replace(char,(char.upper()))
print(Word)
add a comment |
It is actually preety simple to turn all letters in a string to upper case!
just use the variable name and follow .upper() at the end e.g.
byron="byron"
byron=byron.upper()
however, because you want to give only certain letters the "uppercase" status, you'd want to first assign all vowels:
vowels = set(['a','e','i','o','u'])
then use some python logic to do the rest:
for char in byron:
if char in vowels:
Word = Word.replace(char,(char.upper()))
print (Word)
if you want to be quick just copy the code below as it is the complete code used to do your task:
x="byron"
vowels = set(['a','e','i','o','u'])
Word=x
for char in Word:
if char in vowels:
Word = Word.replace(char,(char.upper()))
print(Word)
It is actually preety simple to turn all letters in a string to upper case!
just use the variable name and follow .upper() at the end e.g.
byron="byron"
byron=byron.upper()
however, because you want to give only certain letters the "uppercase" status, you'd want to first assign all vowels:
vowels = set(['a','e','i','o','u'])
then use some python logic to do the rest:
for char in byron:
if char in vowels:
Word = Word.replace(char,(char.upper()))
print (Word)
if you want to be quick just copy the code below as it is the complete code used to do your task:
x="byron"
vowels = set(['a','e','i','o','u'])
Word=x
for char in Word:
if char in vowels:
Word = Word.replace(char,(char.upper()))
print(Word)
answered Nov 22 '18 at 19:59
Coder CodyCoder Cody
408
408
add a comment |
add a comment |
2
"".join([letter.upper() if letter in "aeiouy" else letter for letter in string])
?– L3viathan
Nov 22 '18 at 19:48
Alternative, without comprehensions:
string.translate({97:65, 101:69, 105:73, 111:79, 117:85, 121:89})
– L3viathan
Nov 22 '18 at 19:54