wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (y = 23) {{}} | if (y === 23) {{}} | Use === for equality. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if foo = 4 {{}} | if foo == 4 {{}} | Use ==. | Swift |
DELETE FROM users WHERE age=11 | DELETE FROM users WHERE age=11; | Add semicolon. | SQL |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:88}}; | Add missing property. | TypeScript |
class Product {{ int temp; }}
obj.temp=5; | class Product {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
function compute(result)
print(result)
end | function compute(result)
print(result)
end | Correct. | Lua |
if ($x = 9) | if ($x == 9) | Use ==. | Perl |
print 'data' | print 'data'; | Add semicolon. | Perl |
if temp = 70 | if temp == 70 | Use ==. | MATLAB |
const bar = 72; bar = 50; | let bar = 72; bar = 50; | Cannot reassign const. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
my @arr = (2,100,73); | my @arr = (2,100,73); | Correct. | Perl |
print 'value' | print('value') | print needs parentheses. | Python |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
var x int | var x int | Correct. | Go |
data[80] | if data.indices.contains(80) {{ data[80] }} | Check index. | Swift |
yield val | yield val | Correct yield. | Python |
var y int = 'result' | var y string = 'result' | Type mismatch. | Go |
<person age=74> | <person age="74"> | Quote attribute. | XML |
let result: Int = 'result' | let result: String = 'result' | Fix type. | Swift |
const num; | const num = 66; | Initialize const. | JavaScript |
WHERE email = '22' | WHERE email = 22 | Don't quote integer. | SQL |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
$data[97] = 5; | if (isset($data[97])) $data[97] = 5; | Check existence. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
b = hello | b = 'hello' | Quote strings. | Python |
DELETE FROM items WHERE status=53 | DELETE FROM items WHERE status=53; | Add semicolon. | SQL |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
if (count = 33) | if (count == 33) | Use ==. | C++ |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
INSERT INTO users VALUES ('output',87) | INSERT INTO users (name, email) VALUES ('output',87); | Specify columns. | SQL |
let text1 = String::from("value"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
["info", 74] | ["info", 74] | Correct. | JSON |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
[48, 48, 64 | [48, 48, 64] | Close bracket. | Ruby |
9z = 10 | z9 = 10 | Variable cannot start with digit. | Python |
def bar(result):
return result + 1 | def bar(result):
return result + 1 | Correct. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
name: message
age: 28 | name: message
age: 28 | Correct. | YAML |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
val data: Int = 'value' | val data: String = 'value' | Fix type. | Kotlin |
temp == '15' | temp === 15 | Use strict equality. | JavaScript |
$data[7] | if ($data.Count -gt 7) {{ $data[7] }} | Check bounds. | PowerShell |
if data = 65 | if data == 65 | Use ==. | Go |
String bar = 'info'; | String bar = "info"; | Double quotes. | Java |
val data = 'world' | val data = "world" | Double quotes. | Kotlin |
[37, 40, 64 | [37, 40, 64] | Close bracket. | Python |
'76' + 13 | 76 + 13 | Avoid string coercion. | JavaScript |
class Product {{ int bar; }}; | class Product {{ public: int bar; }}; | Make public. | C++ |
if item = 18 | if item == 18 | Use ==. | Ruby |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
let val: number | null = null; val.toFixed(27); | let val: number | null = null; if(val!==null) val.toFixed(27); | Null check. | TypeScript |
let a = 3; let a = 99; | let a = 3; a = 99; | Duplicate declaration. | JavaScript |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function foo() {{ echo 'value'; }} | function foo() {{ echo 'value'; }} | Correct. | PHP |
let vec=vec![45,37,55]; let head=&vec[0]; vec.push(78); | let mut vec=vec![45,37,55]; let head=vec[0]; vec.push(78); | Copy instead of reference. | Rust |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
switch(index){{ case 69: break; }} | switch(index){{ case 69: break; default: break; }} | Add default case. | Java |
let bar = 96; bar += 1; | let mut bar = 96; bar += 1; | Need mut to modify. | Rust |
if (temp = 51) {{}} | if (temp == 51) {{}} | Use ==. | Kotlin |
int temp = 'test'; | String temp = 'test'; | Type mismatch. | Dart |
baz | baz() | Add parentheses. | Swift |
while x > 50
x -= 1 | while x > 50:
x -= 1 | Colon missing after while. | Python |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<entry name='test'/> | <entry name="test"/> | Double quotes. | XML |
if (val = 75) | if (val == 75) | Use ==. | R |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
jwt.sign({{id:95}}, 'key'); | jwt.sign({{id:95}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
let s = String::from("output"); let ref=&s; s.push_str("!"); | let mut s = String::from("output"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{"age":"message",}} | {{"age":"message"}} | Remove trailing comma. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
values.forEach(function(z) {{ console.log(z); }}) | values.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
items(27) | if length(items) >= 27, items(27), end | Check length. | MATLAB |
[x*x for x in arr if x > 25] | [x*x for x in arr if x > 25] | Correct list comprehension. | Python |
if ($temp = 81) {{}} | if ($temp -eq 81) {{}} | Use -eq. | PowerShell |
let mut index=26; let r1=&mut index; let r2=&mut index; | let mut index=26; {{ let r1=&mut index; }} let r2=&mut index; | Only one mutable borrow. | Rust |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
int[] arr = new int[79];
arr[79] = 5; | int[] arr = new int[79];
if (79 < arr.length) arr[79] = 5; | Check bounds. | Java |
let temp: i32 = "output"; | let temp: &str = "output"; | Type mismatch. | Rust |
function bar() {{
return
{{key:'value'}}
}} | function bar() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
SELECT age email FROM products; | SELECT age, email FROM products; | Add comma. | SQL |
$bar = 42; if ($bar = 42) {{}} | $bar = 42; if ($bar == 42) {{}} | Use ==. | PHP |
list[69] | if (list.indices.contains(69)) list[69] | Check index. | Kotlin |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
local data = 98 | local data = 98 | Correct. | Lua |
if num = 90 then
print('data')
end | if num == 90 then
print('data')
end | Use ==. | Lua |
'message' + 1 | 'message' + 1.to_s | Convert int. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.