33 Answered Questions for the topic String

Understanding tension?

I'm trying to understand tension. So here it goes: I'll start from the beginning. Let's assume I'm in space and can move around and apply forces. Let's say a rope is attached to a body(which is... more

When is tension constant in a rope?

Suppose we have a massless rope with pulling forces applied at each end. In which scenarios is the tension in the rope constant throughout? For example if there is a knot in the rope the tension is... more

Rope tension question?

If two ends of a rope are pulled with forces of equal magnitude and opposite direction, the tension at the center of the rope must be zero. True or false? The answer is false. I chose true though... more


Generate random numeric & alphabetic?

I'm making a random hexadecimal generator is it possible in visual basic to make a code that randomly generates number and letters together? How would you do it? I'm really lost. I'd like to... more


Choose For Random Strings In Commodore 64 BASIC?

I have this variable declarations on my program: X="MAGENTA" Y="CYAN" Z="TAN" A="KHAKI" Now what I want is to randomly choose one of these and `PRINT` it. But how to do this?

How could a cord withstand a force greater than its breaking strength?

How could a 100 N object be lowered from a roof using a cord with a breaking strength of 80 N without breaking the cord? My attempt to answer this question is that we could use a counter weight.... more
String Python List Join


Python join: why is it string.join(list) instead of list.join(string)?

This has always confused me. It seems like this would be nicer: my_list = ["Hello", "world"] print my_list.join("-") # Produce: "Hello-world"Than this: my_list = ["Hello", "world"] ... more


Safe integer parsing in Ruby?

I have a string, say `'123'`, and I want to convert it to `123`.I know you can simply do `some_string.to_i`, but that converts `'lolipops'` to `0`, which is not the effect I have in mind. I want it... more


Why does comparing strings using either '==' or 'is' sometimes produce a different result?

I've got a Python program where two variables are set to the value `'public'`. In a conditional expression I have the comparison `var1 is var2` which fails, but if I change it to `var1 == var2` it... more
String Ruby


How to check whether a string contains a substring in Ruby?

I have a string variable with content as follows: varMessage = "hi/thsid/sdfhsjdf/dfjsd/sdjfsdn\ " "/my/name/is/balaji.so\ " ... more
String Logic Php Boolean


How to parse a string of boolean logic in PHP?

I'm building a PHP class with a private member function that returns a string value such as: 'true && true || false' to a public member function. (This string is the result of some regex... more


Most elegant way to check if the string is empty in Python?

Does Python have something like an empty string variable where you can do: if myString == string.empty:Regardless, what's the most elegant way to check for empty string values? I find hard... more
String Linux Unix Bash


Replacing some characters in a string with another character?

I have a string like <!-- language: lang-none --> AxxBCyyyDEFzzLMN I want to replace all `x` and `y` and `z` with `_` so that the output is A_BC_DEF_LMN How to do that? I know a... more
String Python Count


Count the number occurrences of a character in a string?

What's the simplest way to count the number of occurrences of a character in a string?e.g. count the number of times `'a'` appears in `'Mary had a little lamb'`


How to lowercase a string in Python?

Is there a way to convert a string from uppercase, or even part uppercase to lowercase? E.g. Kilometers --> kilometers.
String Ruby Arrays Split


How to split a delimited string in Ruby and convert it to an array?

I have a string `"1,2,3,4"` and I'd like to convert it into an array: [1,2,3,4]How?
String Ruby


Ruby capitalize every word first letter?

I need to make the first character of every word uppercase, and make the rest lowercase... manufacturer.MFA_BRAND.first.upcaseis only setting the first letter uppercase, but I need this: ALFA... more


Why does "Conversion from string "ID" to type integer is not valid" show on my program?

I'm trying to display my database on textboxes, with the help of the combobox for the ID. However, whenever I run my program, the error **"Conversion from string "ID" to type integer is not... more
String Python


Is there a way to substring a string?

Is there a way to substring a string in Python, to get a new string from the 3rd character to the end of the string?Maybe like `myString[2:end]`?If leaving the second part means 'till the end', if... more


How to read a file line-by-line into a list?

How do I read every line of a file in Python and store each line as an element in a list? I want to read the file line by line and append each line to the end of the list.


Convert bytes to a string?

I'm using this code to get standard output from an external program: >>> from subprocess import * >>> command_stdout = Popen(['ls', '-l'], stdout=PIPE).communicate()[0]The... more


How do I trim whitespace?

Is there a Python function that will trim whitespace (spaces and tabs) from a string?Example: `\  example string\ ` → `example string`
String Python Trim


How do I trim whitespace from a Python string?

How do I remove leading and trailing whitespace from a string in Python?For example: " Hello " --> "Hello" " Hello" --> "Hello" "Hello " --> "Hello" "Bob has a cat" -->... more

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.