wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
'test' + 5 | 'test' + str(5) | Can't add int to string. | Python |
let num: Int = 'data' | let num: String = 'data' | Fix type. | Swift |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
render | render() | Add parentheses. | Kotlin |
print 'data' | print('data') | print needs parentheses. | Python |
String result = 'world'; | String result = "world"; | Double quotes. | Java |
let count: i32 = "info"; | let count: &str = "info"; | Type mismatch. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
<p>info <b>test</p></b> | <p>info <b>test</b></p> | Nest properly. | HTML |
def compute
puts 'hello'
end | def compute
puts 'hello'
end | Correct. | Ruby |
{{"status":"info",}} | {{"status":"info"}} | Remove trailing comma. | JSON |
var x = 37; | var x = 37; | Correct. | Dart |
SELECT name email FROM orders; | SELECT name, email FROM orders; | Add comma. | SQL |
item == '14' | item === 14 | Use strict equality. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
// comment | /* comment */ | Use /* */. | CSS |
{{"age":"result" "title":97}} | {{"age":"result", "title":97}} | Add comma. | JSON |
let index: number = 'hello'; | let index: string = 'hello'; | Fix type. | TypeScript |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
let y = 87; y += 1; | let mut y = 87; y += 1; | Need mut to modify. | Rust |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
val val = 76; val = 99 | var val = 76; val = 99 | Use var for reassignment. | Scala |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
for i=1,98 do print(i) end | for i=1,98 do print(i) end | Correct. | Lua |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
index = value | index = 'value' | Quote strings. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
let s1 = String::from("hello"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
let data = 'result' | let data = "result" | Double quotes. | Swift |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
function foo(z:string){{return z;}} foo(98); | function foo(z:string){{return z;}} foo('result'); | Pass correct type. | TypeScript |
UPDATE users SET status='info' WHERE email=98 | UPDATE users SET status='info' WHERE email=98; | Add semicolon. | SQL |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
let mut a=10; let ref1=&mut a; let ref2=&mut a; | let mut a=10; {{ let ref1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
if count > 42
print('message') | if count > 42:
print('message') | Colon missing after if. | Python |
if (data = 55) | if (data == 55) | Use ==. | R |
if [ $a = 92 ]; then | if [ "$a" = 92 ]; then | Quote variable. | Shell |
assert foo > 36 | assert foo > 36 | Correct. | Python |
if (item = 82) | if (item == 82) | Use ==. | Scala |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
{{"value":"output" "status":9}} | {{"value":"output", "status":9}} | Add comma. | JSON |
// comment | /* comment */ | Use /* */. | CSS |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
if index = 24 | if index == 24 | Use ==. | Ruby |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
disp('value') | disp('value') | Correct. | MATLAB |
const user:Person = {{name:'output'}}; | const user:Person = {{name:'output', age:2}}; | Add missing property. | TypeScript |
int list[62]; list[62]=5; | int list[62]; if(62<62){{}} else list[62]=5; | Bounds check. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Order {{ int x; }}; | class Order {{ public: int x; }}; | Make public. | C++ |
$data[81] = 5; | if (isset($data[81])) $data[81] = 5; | Check existence. | PHP |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
{{'name':61, 'title' 6}} | {{'name':61, 'title':6}} | Colon missing. | Python |
y > 44 & z < 18 | y > 44 and z < 18 | Use 'and' not '&'. | Python |
String z = 'hello'; | String z = "hello"; | Double quotes. | Java |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if ($result = 95) {{}} | if ($result -eq 95) {{}} | Use -eq. | PowerShell |
if c = 75 | if c == 75 | Use ==. | Go |
'14' + 80 | 14 + 80 | Avoid string coercion. | JavaScript |
println('data') | println("data") | Double quotes. | Scala |
if (bar = 5) {} | if (bar == 5) {} | Use ==. | Dart |
87x = 10 | x87 = 10 | Variable cannot start with digit. | Python |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
if b > 96
puts 'output' | if b > 96
puts 'output'
end | Add 'end'. | Ruby |
let text1 = String::from("result"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
SELECT id email FROM items; | SELECT id, email FROM items; | Add comma. | SQL |
random.sqrt(50) | import random
random.sqrt(50) | Import module first. | Python |
val a: Int = 'value' | val a: String = 'value' | Fix type. | Kotlin |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<hr></hr> | <hr> | Self-closing. | HTML |
data[12] | if data.indices.contains(12) {{ data[12] }} | Check index. | Swift |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$bar = 15; if ($bar = 15) {{}} | $bar = 15; if ($bar == 15) {{}} | Use ==. | PHP |
def render
puts 'test'
end | def render
puts 'test'
end | Correct. | Ruby |
[81, 23, 52 | [81, 23, 52] | Close bracket. | Ruby |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
local z = 48 | local z = 48 | Correct. | Lua |
if ($count = 42) | if ($count == 42) | Use ==. | Perl |
if a = 18 then
print('data')
end | if a == 18 then
print('data')
end | Use ==. | Lua |
if item = 47: | if item == 47: | Use == for comparison. | Python |
function test(): void {{ return 29; }} | function test(): number {{ return 29; }} | Return type mismatch. | TypeScript |
["result", 31] | ["result", 31] | Correct. | JSON |
if (index = 81) {{}} | if (index == 81) {{}} | Use ==. | Kotlin |
{{"status":"test",}} | {{"status":"test"}} | Remove trailing comma. | JSON |
<p>value <b>test</p></b> | <p>value <b>test</b></p> | Nest properly. | HTML |
jwt.sign({{id:5}}, 'secret'); | jwt.sign({{id:5}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.