8/11 badly stuck


#1

pyg = 'ay'
word = "original"
word = word.lower()
original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    first = word[0]
    print original
    
else:
    print 'empty'

please tell me what i am doing wrong.:frowning:


#2

The exercise says:

Inside your if statement:

Create a new variable called word that holds the .lower()-case conversion of original.Create a new variable called first that holds word[0], the first letter of word.

What you've done wrong is, creating the variable word outside the if statement, it must be inside. Secondly, it doesn't say anywhere in the explanation to store a string the exercise says "create a new variable called word that holds the .lower() case conversion of the variable original", delete the line with word = "original".
Let me know if you need any further help!


#3

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
word = original.lower()
first = "word"[0]
print word
else:
print 'empty'
First of all Thank you @xsorax
i further have question, when i am doing this i am going to the next exercise, i mean they say it is okay..

but first letter of the word is not printing, why is it so?


#4

No need to thank me @systemace80996 :smile: we are all here to help each other out!
What you are doing wrong is storing in the variable first "word"[0], you are storing it as a string and it won't work that way:
first = "word"[0]
Thats the source of your problem, I don't want to give you the code straight as it could help you advancing and get better if you find the solution on your own, but remember Python treats as a string everything that's inside the " " what you have to do is storing the variable word.
Let me know if it wasn't clear enough!


#5

Try this
original = raw_input("Enter a Word:-").lower()
if len(original) > 0 and original.isalpha():
print(original)
word = original
first = word[0]
new_word = word + first + "py"
new_word = new_word[1:len(new_word)]
print(new_word)
else:
print("Empty")


#6

That's totally wrong.
First of all the exercise is referring to the creation of the variable first not new_word, you are just simply confusing him that way, also new_word declaration is wrong, you've written:
new_word = word + first + "py" when it should be:
new_word = word + first + pyg

Also the variable original considering the exercise is wrong, you've stored .lower() in original instead of word.


#7

yep this is 9th exercise. :smiley:


#8

@systemace80996 How's the exercise going? did you went through it? if you need anything dont hesitate to ask!


#9

There is something with this exercise, it says start new lesson. I don't understand.
@xsorax:frowning:
first = word[0]
but it is not giving the desirable result.


#10

Show me how your full code looks now @systemace80996 :grin:


#11

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]

else:
print 'empty'


#12

yes i did
first i created a variable named original and i put the users input,
then i declared another variable named word, purpose to keep the copy of the value of original
then i declared another variable named first, purpose to keep first letter of my input
another variable new_word used for combining or concatenating all
then this variable is processed from which index to which index r 2 b printed

thats all it's d logic


#13

Your code is good now @systemace80996 you just missed print original inside the if statement :smile: add print original after first = word[0] and you're good to go!

Also check the hint in the exercise:
Note: You can print out the values of the variables word and first to double-check your work (remove these print statements when you're done debugging).

to check if everything is working as desired add print word and print first just remember to delete it before going to the next exercise!
Let me know if you need anything else :smile:


#14

The purpose of the exercise is to create a variable word and add original.lower() there, not inside the variable original, which is not really wrong, but it doesn't serve in the purpose of the exercise and it's not written anywhere to store .lower() inside original it just confused the guy even more.

Also, where's the variable pyg the exercise referred to? nowhere, when you were supposed to declare:
pyg = 'ay'
and then in your new_word variable you stored:
new_word = word + first + "py"
That's wrong, it's supposed to be:
new_word = word + first + pyg

Let's respect the purposes of the exercise, otherwise there is no way people can learn as it only lead to more confusion especially to new people trying to learn from here.


#15

ok i thought that lower the coding means quicker the process


#16

It's not really wrong, but IMHO respecting the exercise would be more educative, otherwise how do we learn?
It's not really necessary to make processing quickier always but the opposite, following the exercise will help everybody learning more efficiently :smile:

Regarding the exercise itself, I hope my explanation were clear and that everything is working now, whether you guys need anything feel free to ask!


#17

done with 9 th exercise , thank you guys :stuck_out_tongue:


#18

2 posts were split to a new topic: Coming up ‘empty’


#19