if-else-else if statements in Java (codecademy)

I’m just starting to learn Java and I just got to the if-else-else if statements section on CodeAcademy. I tried using the if else statement in a method, but I’m not receiving the variable value when I call it, only the if-else statement. I’m guessing this is a very small mistake. (This is my first… Read More if-else-else if statements in Java (codecademy)

Python functions not running correctly

I’ve written this code to convert a string to uppercase and lowercase, however when I call my functions, it doesn’t run. # take the input for the string string = input("Enter any string: ") def string_upper(up): return up.upper() print("Uppercase Output: ", string_upper(string)) def string_lower(low): return low.lower() print("Lowercase Output: ", string.lower(string)) if __name__ == "__main__": string_upper(up)… Read More Python functions not running correctly

Operator function defaults to first if statement in JavaScript calculator project

I’m creating a calculator with JavaScript and most functions are working properly, but the operator function defaults to the first if statement each time (I switched add with subtract to test this). i.e. if the add function is in the first if statement of my operator function, every operator button will add the numbers instead… Read More Operator function defaults to first if statement in JavaScript calculator project

passing argument 1 and 2 of ‘strcmp’ makes pointer from integer without a cast [-Wint-conversion]

Hello so I’ve been working a little prgramme which is sort of a calculator (I’m a beginner) and well as you can see in the tittle at then end of the code, the two if strcmp doesn’t work. And vscode is telling me (for the strcmp) Exception has occurred. Segmentation fault. But gcc is telling… Read More passing argument 1 and 2 of ‘strcmp’ makes pointer from integer without a cast [-Wint-conversion]

Why is the std::vector not giving any outputs in c++

I don’t understand why but the std::vector is not giving anything after i put a class pointer in the array. // runs at start void States::AssignState(GameState* state) { _nextVacentState++; _states.push_back(state); } // executes in a loop void States::ExecuteCurrentState() { // protection incase there is nothing in the array or the current state is not grater… Read More Why is the std::vector not giving any outputs in c++

Understanding string variable substitution in a python list comprehension

I am not sure on the syntax being used in a list comprehension example in the Python Cookbook. Code (with my print statements in) is below: import html # to accept any number of KEYWORD arguments, use ** # treat the argument as a dictionary def make_element(name, value, **attrs): print(f"attrs has type {type(attrs)}") print(f"attrs ->… Read More Understanding string variable substitution in a python list comprehension