Python Forum

Full Version: GROK MODULE 5 HELP!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
name = input('Cheer: ')
print('Give me a',name,name[0],'!')
print('Give me a,',name[1])
print('Give me a,',name[2])
print('Give me a,',name[3])
print('Give me a,',name[4])
print('Give me a,',name[5])
print('Give me a,',name[6])
print('Give me a,',name[7])
Output:
Cheer: gryffindor Give me a g, g! Give me a r, r! Give me a y, y! Give me a f, f! Give me a f, f! Give me a i, i! Give me a n, n! Give me a d, d! Give me a o, o! Give me a r, r! What does it spell? GRYFFINDOR
GRok learning is not really that helpful, unfortunately I am required to use this platform to learn python. If anyone can help point me towards the right direction please dont use complex terms and excpect me to understand lol. just show me an image if you can. please and thank you guys ! This forum has helped me
This is what for loops are for.
>>> name = 'gryffindor'
>>> for letter in name:
...     print(f'Give me a {letter}, {letter}!')
... 
Give me a g, g!
Give me a r, r!
Give me a y, y!
Give me a f, f!
Give me a f, f!
Give me a i, i!
Give me a n, n!
Give me a d, d!
Give me a o, o!
Give me a r, r!
>>> print(f'What does that spell? {name.upper()}')
What does that spell? GRYFFINDOR