Detect whether a Python string is a number or a letter

Check if string is nonnegative digit (integer) and alphabet You may use str.isdigit() and str.isalpha() to check whether a given string is a nonnegative integer (0 or greater) and alphabetical character, respectively. Sample Results: Check for strings as positive/negative – integer/float str.isdigit() returns False if the string is a negative number or a float number. For example: If you want to also check for the negative integers and float, then you may … Read more

java.net.UnknownHostException: Invalid hostname for server: local

What the exception is really saying is that there is no known server with the name “local”. My guess is that you’re trying to connect to your local computer. Try with the hostname “localhost” instead, or perhaps 127.0.0.1 or ::1 (the last one is IPv6). From the javadocs: Thrown to indicate that the IP address of a host could not be determined. … Read more

Change default title in mac terminal window

That’s two questions: the text in the titlebar for OSX Terminal comes from the names of the processes running in the terminal. There can be multiple levels of processes, e.g., a shell running an editor. Terminal shows up to a few levels of those. You can configure its behavior in the Preferences dialog. In practice, it can … Read more

Express Render not working return error: No default engine was specified and no extension was provided

I’m writing an Express application without a template engine I am using just using HTML as the template engine. app.set(‘view engine’, ‘html’); actually, the whole code was generated using express-generator and I set the view to –no-view Flag and the index URL page runs well but trying another URL like users or any other except the index URL does … Read more

Vim Can’t Save File (E212)

This will ask you for the root password, then save your changes as you requested: Then type (L)oad at the prompt, to re-load the file after it is saved.

How to move 2D Object with WASD in Unity

You don’t need those if statements. Just use += to append the input to the current transform position. Move without Rigidbody: Move Object with Rigidbody2D: I suggest using the second code and moving the Rigidbody if you want to be able to detect collison later on. Note: You must assign the object to move to the obj slot in the Editor. If using … Read more

What is sys.maxint in Python 3?

The sys.maxint constant was removed, since there is no longer a limit to the value of integers. However, sys.maxsize can be used as an integer larger than any practical list or string index. It conforms to the implementation’s “natural” integer size and is typically the same as sys.maxint in previous releases on the same platform … Read more

What are the differences between struct and class in C++?

You forget the tricky 2nd difference between classes and structs. Quoth the standard (§11.2.2 in C++98 through C++11): In absence of an access-specifier for a base class, public is assumed when the derived class is declared struct and private is assumed when the class is declared class. And just for completeness’ sake, the more widely known difference between class and … Read more

Invalid or unexpected token on a very simple function

Just a non-ascii-character \xe2 at the end of your function braces. Open developer tool > console and paste your code. You will see a red dot over there which indicates an invalid character. Just remove that invalid character (check image below).