Hello guys i want to convert this string to boolean and i'm passing this string in if condition
my Str = "row(0).ToString.Contains(""ABC"")"
it should return me boolean result as the condition follows

I'm Making use of this in Uipath

Recommended Answers

All 3 Replies

There is a syntax error and a logic error I can see in this. First, a variable name is always 1 word, with no spaces in it. You could use an underscore (_), but it is generally not needed. Also you should make your variable names descriptive of their use. Second, putting quotes (") around the line, as shown, turns that into a string literal so that text will be assigned as stated to the string variable on the left; it will not be evaluated as you intend. Third, what is the type of row(0)? Does it make sense to convert it to a string using ToString? I think you intended:

myStr = row(0).ToString().Contains("ABC")

In UiPath, you can convert the given string into a boolean value using the "Boolean" activity. First, assign the string to a variable, let's call it "MyStr." Then, use the following expression in the "Assign" activity:

MyBool = Convert.ToBoolean(row(0).ToString.Contains("ABC"))

This will convert the string condition into a boolean value and store it in the variable "MyBool." You can then use "MyBool" in the if condition for further processing.

Hi,

I've reviewed it, and it looks great! However, I noticed a small error in your code that might be causing the issue you mentioned. In the is_gussed function, there's a typo in the increment statement for the count variable. It should be count += 1 instead of count += 1:. The colon at the end of the line should be removed. Here's the corrected function:

def is_gussed(word, guessed_letter_list):
    count = 0
    for letter in word:
        if letter in guessed_letter_list:
            count += 1
    if count == len(word):
        return True
    else:
        return False

With this correction, the program should run without any errors. Additionally, I noticed that you have two print statements for the hangman's body inside the hangman_game function. You might want to consider removing the second one so that the hangman's body is displayed only once when the player loses the game.

Apart from that, your implementation looks good, and it's a fun hangman game! Keep up the good work, and if you encounter any other issues or need further assistance, feel free to ask.

Happy coding!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.