Brain.print() in Vex VR switching between single and double quotes

I created a lesson to teach variables to my students in Vex VR. It uses the brain.print() command to write the variable out to the console regularly, so they can see the effects of changing variable values or doing operations on them. I originally wrote the lesson using double quotes for string values because that’s what I used in my testing: brain.print("This is a string variable ")

The first student to go through the lesson pointed out that it wasn’t working double quotes, so i assumed that i’d written it out wrong because single quotes worked for them, that way. The second student to try to use it also expressed concern because when they tried to use it (probably on a different computer) with single quotes, it didn’t work. Double quotes worked for them.

At this point, i opened it on my computer and both double and single quotes worked for me. I reviewed both of their code and one worked only with single quotes while the other worked only with double quotes and mine worked with both.

The help examples all show double quotes.

Is there a configuration somewhere that i need to make sure is the same on all the computers?

Can you send the code that you and your 2 students wrote?

Single and double quotes should work in Python.
The only thing that could be wrong is putting single quotes inside of single quotes and/or double quotes inside of double quotes.

We’ll be able to debug better based on your code samples.

Here is a snippet from the middle or the lesson, where we start to address string variables:

In addition to numbers, you can also create other types of variables. One of the most useful is a ‘string’ type - that is, a string of alpha-numeric characters jammed together. For instance:

stringBox = ‘string of characters ‘

brain.print(stringBox)

Stop the video and run the code here.

That did what it’s supposed to, but “24string of characters” is a bit difficult to read. We can make that easier to read by adding a line break after each thing we print. Your whole code should now look like this:

numericBox = 2

brain.print(numericBox)

brain.new_line()

anotherBox = numericBox + 2

brain.print(anotherBox)

brain.new_line()

stringBox = ‘string of characters ‘

brain.print(stringBox)

brain.new_line()

Run that and you’ll see how much easier it is to read.

Great! You can also add strings together, but they don’t add like numbers. Let’s include this:

stringBox = stringBox + ‘that can be added’

brain.print(stringBox)

brain.new_line()

What?! This is a special type of adding that we call “concatenation.” Python added the second string to the end of the first string (which was already in the box) and came up with a long string of characters. Notice also that stringBox is on both sides of the statement {stringBox = stringBox + ‘that can be added.} This is not a mistake - it’s a bit of syntactic sugar. Python (and most other languages) use the order of operations to allow you to use the current value of a variable on the right side of the equals sign in the calculation that results in the value on the left. Once the calculation is done, the new value will be the result of the calculation and the old value will be forgotten.


In the first version of the lesson, ‘string of characters ‘ was wrapped in double quotes (i use C# more than SQL) and a student ran into trouble with that. i looked at her code and it was all right, so we changed it to single quotes and it worked. Based on that, i updated the lesson to single quotes everywhere i had double quotes for string values. I did not try it on my machine, i saw that only single quotes worked on her machine, so i updated the lesson to all single quotes instead of double.

When the next student tried the same lesson, it didn’t work again, and i found that only double quotes worked for him. It’s likely it was a different computer from the first, but all of our computers are the same model of Lenovo running updated Windows 11, so they should work roughly the same.

i thought, “huh - i thought i updated the lesson, but maybe i didn’t.” We tried double quotes, and it worked. Then i went back to the lesson history and i can see that i did update the lesson. So, i tried it on my personal computer, which is an HP Envy running the latest Windows - and unexpectedly, both single and double quotes worked for me.

Either of the students could have typed it out, but it’s more likely that they copied it from the Google page i shared with them. Either way, i reviewed both and they were correct. I typed it instead of copying it on my laptop and probably had them just type the quote changes when we changed them.

I hope that’s enough information, but i’ll be happy to provide any more that i can.

My guess is this may be the problem.

Google, and other online documents, tend to replace the simple single and double quotes with fancy unicode versions that the Python interpreter may not understand. I’ve seen this problem often with students copy/pasting C++ code which then will not compile.

Perhaps try a simple program typed directly and see what happens, Python should accept either double or single as long as opening and closing match.