Solution and Explanation : clcoding.com/2023/12/python…
@clcoding Option a). c Why!? - The string 'clcoding' is assigned to the variable msg. Now, you want to access the first character of this string. In Python, indexing starts from 0, so the first character is at index 0. - However, the index -0 is equivalent to 0, so you can simplify
@clcoding Answer: A Solution: msg = 'clcoding' assigns the value 'clcoding' to the variable `msg`. Then, ch = print(msg[-0]) Let's go in sequence here. This is basically an assignment statement. In any assignment statement, the Right Hand Side is evaluated first. Here +
@clcoding The answer is A because -0 will still result to 0 Python devs let's follow each other 🥺
@clcoding Output is c. -0 or 0 both are one and same. Element at index 0 of msg is c, which is the output. Remember index in Python starts at 0.
@clcoding My first thought is G, heres why a noob thinks that, [-0] looks like no index so -0 the negative jumps to the last index, 0 says no more then that. Im wrong maybe but thats how a newb sees it, if you pros ever wondered
@clcoding A) c Should be A cuz -0 is still 0 and it's probably when it's at -1 that it will be g
@clcoding Answer: [A] msg[-0] is the same as msg[0] which is 'c'
@clcoding A) c As 0 is neither positive nor negative, it is taken as a normal index. Acts like 0.
@clcoding In Python, indexing with '-0' is valid, and it behaves the same as indexing with '0'. So, msg[-0] and msg[0] both refers to the first character of the string. So the output would be : 'C'
@clcoding C.) Error, because the print function cannot be assigned to a variable.
@clcoding wow day 97 of your coding challenge thats impressive keep up the great work what was the output of your python code today im curious