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.
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.
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!
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?
No need to thank me @systemace80996 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!
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â)
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.
yep this is 9th exercise.
@systemace80996 Howâs the exercise going? did you went through it? if you need anything dont hesitate to ask!
There is something with this exercise, it says start new lesson. I donât understand.
@xsorax:(
first = word[0]
but it is not giving the desirable result.
pyg = âayâ
original = raw_input(âEnter a word:â)
if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]
else:
print âemptyâ
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
Your code is good now @systemace80996 you just missed print original inside the if statement 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
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.
ok i thought that lower the coding means quicker the process
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
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!
done with 9 th exercise , thank you guys