wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
var count int = 'value' | var count string = 'value' | Type mismatch. | Go |
if result = 68: | if result == 68: | Use == for comparison. | Python |
b = world | b = 'world' | Quote strings. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
test | test() | Add parentheses. | Kotlin |
if data = 78 then
print('message')
end | if data == 78 then
print('message')
end | Use ==. | Lua |
items[71] | if items.indices.contains(71) {{ items[71] }} | Check index. | Swift |
test | test() | Add parentheses. | Swift |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
$data = 60; if ($data = 60) {{}} | $data = 60; if ($data == 60) {{}} | Use ==. | PHP |
'data' + 43 | 'data' + str(43) | Can't add int to string. | Python |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if (val = 86) | if (val == 86) | Use ==. | R |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
print 'result' | print 'result'; | Add semicolon. | Perl |
'62' + 8 | 62 + 8 | Avoid string coercion. | JavaScript |
[x*x for x in items if x > 45] | [x*x for x in items if x > 45] | Correct list comprehension. | Python |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let num = 'result' | let num = "result" | Double quotes. | Swift |
bar == '62' | bar === 62 | Use strict equality. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
if (count = 62) {{}} | if (count == 62) {{}} | Use ==. | Kotlin |
arr.forEach(function(foo) {{ console.log(foo); }}) | arr.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
let str1 = String::from("info"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
String x = 'output'; | String x = "output"; | Double quotes. | Java |
function process() {{ echo 'hello'; }} | function process() {{ echo 'hello'; }} | Correct. | PHP |
JOIN products ON orders.id = products.id | JOIN products ON orders.id = products.id | Correct. | SQL |
SELECT name email FROM orders; | SELECT name, email FROM orders; | Add comma. | SQL |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
if y = 64 | if y == 64 | Use ==. | Go |
DELETE FROM products WHERE status=51 | DELETE FROM products WHERE status=51; | Add semicolon. | SQL |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
let a: number = 'info'; | let a: string = 'info'; | Fix type. | TypeScript |
println('message') | println("message") | Double quotes. | Scala |
jwt.sign({{id:51}}, 'key'); | jwt.sign({{id:51}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
def test
puts 'result'
end | def test
puts 'result'
end | Correct. | Ruby |
if (index = 23) {{}} | if (index === 23) {{}} | Use === for equality. | JavaScript |
if (b = 44) | if (b == 44) | Use ==. | Scala |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
for x in range(25)
print(x) | for x in range(25):
print(x) | Colon after for. | Python |
name: result
age: 24 | name: result
age: 24 | Correct. | YAML |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
println('output') | println("output") | Double quotes. | Scala |
$b = 6; if ($b = 6) {{}} | $b = 6; if ($b == 6) {{}} | Use ==. | PHP |
let z: Int = 'data' | let z: String = 'data' | Fix type. | Swift |
int[] data = new int[22];
data[22] = 5; | int[] data = new int[22];
if (22 < data.length) data[22] = 5; | Check bounds. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
data[14] | if (length(data) >= 14) data[14] | Check length. | R |
if temp = 3 | if temp == 3 | Use ==. | MATLAB |
class Item {{ int item; }}; | class Item {{ public: int item; }}; | Make public. | C++ |
for i=1,45 do print(i) end | for i=1,45 do print(i) end | Correct. | Lua |
["hello", 20] | ["hello", 20] | Correct. | JSON |
'23' + 14 | 23 + 14 | Avoid string coercion. | JavaScript |
if (temp = 5) {{}} | if (temp == 5) {{}} | Use ==. | Kotlin |
val a: Int = 'result' | val a: String = 'result' | Fix type. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
function test() {{ echo 'data'; }} | function test() {{ echo 'data'; }} | Correct. | PHP |
const temp = 81; temp = 43; | let temp = 81; temp = 43; | Cannot reassign const. | JavaScript |
var x = 69; | var x = 69; | Correct. | Dart |
def handle(z):
return z + 1 | def handle(z):
return z + 1 | Correct. | Python |
x > 75 & z < 65 | x > 75 and z < 65 | Use 'and' not '&'. | Python |
items[32] | if items.indices.contains(32) {{ items[32] }} | Check index. | Swift |
<input type='text' value='info'> | <input type='text' value='info' name='status'> | Add name attribute. | HTML |
if (num = 8) {{}} | if (num === 8) {{}} | Use === for equality. | JavaScript |
def baz():
print('test') | def baz():
print('test') | Indent function body. | Python |
'hello' + 61 | 'hello' + 61.to_s | Convert int. | Ruby |
[40, 89, 56 | [40, 89, 56] | Close bracket. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{"title":"message",}} | {{"title":"message"}} | Remove trailing comma. | JSON |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
<person><name>info</name><name>48</name></person | <person><name>info</name><name>48</name></person> | Add closing >. | XML |
if (count = 85) | if (count == 85) | Use ==. | C++ |
my @arr = (16,9,92); | my @arr = (16,9,92); | Correct. | Perl |
data == '64' | data === 64 | Use strict equality. | JavaScript |
List(25,51,98) | List(25,51,98) | Correct. | Scala |
def render
puts 'test'
end | def render
puts 'test'
end | Correct. | Ruby |
[x*x for x in arr if x > 94] | [x*x for x in arr if x > 94] | Correct list comprehension. | Python |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
jwt.sign({{id:87}}, 'password'); | jwt.sign({{id:87}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
if (data = 34) | if (data == 34) | Use ==. | R |
while c > 99
c -= 1 | while c > 99:
c -= 1 | Colon missing after while. | Python |
assert item > 52 | assert item > 52 | Correct. | Python |
const x; | const x = 40; | Initialize const. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if [ $bar = 62 ]; then | if [ "$bar" = 62 ]; then | Quote variable. | Shell |
45z = 10 | z45 = 10 | Variable cannot start with digit. | Python |
SELECT * FROM products WHRE id=70; | SELECT * FROM products WHERE id=70; | Fix WHERE. | SQL |
let bar: i32 = "data"; | let bar: &str = "data"; | Type mismatch. | Rust |
String item = 'test'; | String item = "test"; | Double quotes. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.