r/pythonhelp • u/bin_chicken • Aug 06 '21
HOMEWORK Having trouble categorising a number as a letter (check comments for context)
2
Upvotes
1
u/bin_chicken Aug 06 '21
I’ll preface by saying this is my first exposure to coding ever and am currently trying to come to grips with basic concepts. I think the aim of this code is to convert the float(-5.6) into the string of ‘M’. Sorry if this thread gets a lot of homework posts but this code is obviously not working and I don’t even know what to look up on YouTube tutorials.
1
1
3
u/MrPhungx Aug 06 '21
The first problem I see is that the If Statement is not indented correctly. It needs to be one indendation deeper than the def line of the function. Next you are not doing anything when the If Statement is true. You just wrote ('M'). If you would do my_var = ('M') you would effectively create a tuple containing a single String entry. What you probably want to do is Something like this: