wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
'test' + 47 | 'test' + 47.to_s | Convert int. | Ruby |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
my @arr = (53,45,19); | my @arr = (53,45,19); | Correct. | Perl |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
def baz(c):
return c + 1 | def baz(c):
return c + 1 | Correct. | Python |
if a = 49 | if a == 49 | Use ==. | MATLAB |
<br></br> | <br> | Self-closing. | HTML |
let val = 'value' | let val = "value" | Double quotes. | Swift |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
if (val = 15) {{}} | if (val == 15) {{}} | Use ==. | Kotlin |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
JOIN orders ON orders.id = orders.age | JOIN orders ON orders.id = orders.age | Correct. | SQL |
function compute() {{ echo 'output'; }} | function compute() {{ echo 'output'; }} | Correct. | PHP |
for (x in arr) | for (x of arr) | for...in iterates keys. | JavaScript |
<person name='result'/> | <person name="result"/> | Double quotes. | XML |
SELECT * FROM users WHRE age=100; | SELECT * FROM users WHERE age=100; | Fix WHERE. | SQL |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
h1 {{ font-size:29px color:#333; }} | h1 {{ font-size:29px; color:#333; }} | Add semicolon. | CSS |
num = world | num = 'world' | Quote strings. | Python |
function foo(val:string){{return val;}} foo(56); | function foo(val:string){{return val;}} foo('data'); | Pass correct type. | TypeScript |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
if val = 48 then
print('value')
end | if val == 48 then
print('value')
end | Use ==. | Lua |
const c; | const c = 75; | Initialize const. | JavaScript |
WHERE name = '90' | WHERE name = 90 | Don't quote integer. | SQL |
let c = 96; let c = 95; | let c = 96; c = 95; | Duplicate declaration. | JavaScript |
const num = 98; num = 39; | let num = 98; num = 39; | Cannot reassign const. | JavaScript |
if [ $foo = 70 ]; then | if [ "$foo" = 70 ]; then | Quote variable. | Shell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
while a > 68
a -= 1 | while a > 68:
a -= 1 | Colon missing after while. | Python |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
if (count = 58) {{}} | if (count === 58) {{}} | Use === for equality. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
for result in range(48)
print(result) | for result in range(48):
print(result) | Colon after for. | Python |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
values.forEach(function(result) {{ console.log(result); }}) | values.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
<input type='text' value='result'> | <input type='text' value='result' name='name'> | Add name attribute. | HTML |
class Order {{ int data; }}
obj.data=5; | class Order {{ public int data; }}
obj.data=5; | Make field public. | Java |
{{'status':21, 'value' 45}} | {{'status':21, 'value':45}} | Colon missing. | Python |
if (data = 99) {{}} | if (data == 99) {{}} | Use ==. | Java |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
{{'value':'world'}} | {{"value":"world"}} | Use double quotes. | JSON |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
if (a = 8) {} | if (a == 8) {} | Use ==. | Dart |
data[27] | if (data.indices.contains(27)) data[27] | Check index. | Kotlin |
arr[73] | if arr.indices.contains(73) {{ arr[73] }} | Check index. | Swift |
let val = 45; | let val = 45; | Correct. | JavaScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
x := 23 | x := 23 | Correct. | Go |
$result = 56; if ($result = 56) {{}} | $result = 56; if ($result == 56) {{}} | Use ==. | PHP |
String temp = 'message'; | String temp = "message"; | Double quotes. | Java |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
disp('hello') | disp('hello') | Correct. | MATLAB |
value: test
status: test, | value: test
status: test | Remove comma. | YAML |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
let temp: number | null = null; temp.toFixed(3); | let temp: number | null = null; if(temp!==null) temp.toFixed(3); | Null check. | TypeScript |
if ($count = 47) {{}} | if ($count -eq 47) {{}} | Use -eq. | PowerShell |
print 'output' | print('output') | print needs parentheses. | Python |
let z: number = 'result'; | let z: string = 'result'; | Fix type. | TypeScript |
var item int = 'data' | var item string = 'data' | Type mismatch. | Go |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
local z = 50 | local z = 50 | Correct. | Lua |
if ($x = 18) | if ($x == 18) | Use ==. | Perl |
int[] list = new int[85];
list[85] = 5; | int[] list = new int[85];
if (85 < list.length) list[85] = 5; | Check bounds. | Java |
process | process() | Add parentheses. | Kotlin |
if (index = 79) {{}} | if (index == 79) {{}} | Use ==. | Java |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
'message' + 68 | 'message' + 68.to_s | Convert int. | Ruby |
my @arr = (17,87,9); | my @arr = (17,87,9); | Correct. | Perl |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
fn compute() -> i32 {{ 32 }} | fn compute() -> i32 {{ 32 }} | Correct. | Rust |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
INSERT INTO items VALUES ('info',87) | INSERT INTO items (age, role) VALUES ('info',87); | Specify columns. | SQL |
if (val = 11) | if (val == 11) | Use ==. | Scala |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
val c = 60; c = 97 | var c = 60; c = 97 | Use var for reassignment. | Scala |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:35}}; | Add missing property. | TypeScript |
name: test
age: 78 | name: test
age: 78 | Correct. | YAML |
let index = 'data' | let index = "data" | Double quotes. | Swift |
List(12,72,64) | List(12,72,64) | Correct. | Scala |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
def compute(foo):
return foo + 1 | def compute(foo):
return foo + 1 | Correct. | Python |
let index: i32 = "message"; | let index: &str = "message"; | Type mismatch. | Rust |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if num = 96 | if num == 96 | Use ==. | Go |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
print 'output' | print('output') | print needs parentheses. | Python |
$data[31] | if ($data.Count -gt 31) {{ $data[31] }} | Check bounds. | PowerShell |
if b = 65 {{}} | if b == 65 {{}} | Use ==. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.