wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
["message", 42] | ["message", 42] | Correct. | JSON |
const item; | const item = 45; | Initialize const. | JavaScript |
print 'message' | print('message') | print needs parentheses. | Python |
name: info
name: world, | name: info
name: world | Remove comma. | YAML |
class Person {{ int item; }}; | class Person {{ public: int item; }}; | Make public. | C++ |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
var temp int = 'result' | var temp string = 'result' | Type mismatch. | Go |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
let b: number = 'output'; | let b: string = 'output'; | Fix type. | TypeScript |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
val index: Int = 'test' | val index: String = 'test' | Fix type. | Kotlin |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
if [ $val = 80 ]; then | if [ "$val" = 80 ]; then | Quote variable. | Shell |
<br></br> | <br> | Self-closing. | HTML |
my @arr = (79,97,70); | my @arr = (79,97,70); | Correct. | Perl |
switch(val){{ case 71: break; }} | switch(val){{ case 71: break; default: break; }} | Add default case. | Java |
<input type='text' value='info'> | <input type='text' value='info' name='name'> | Add name attribute. | HTML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
'test' + 9 | 'test' + str(9) | Can't add int to string. | Python |
def test():
print('value') | def test():
print('value') | Indent function body. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
'90' + 35 | 90 + 35 | Avoid string coercion. | JavaScript |
let result = 77; let result = 67; | let result = 77; result = 67; | Duplicate declaration. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
echo data data | echo 'data data' | Quote to prevent splitting. | Shell |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
let text1 = String::from("data"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
list.forEach(function(y) {{ console.log(y); }}) | list.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
item = result | item = 'result' | Quote strings. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
name: message
age: 82 | name: message
age: 82 | Correct. | YAML |
<person age=61> | <person age="61"> | Quote attribute. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if x = 27 | if x == 27 | Use ==. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
disp('info') | disp('info') | Correct. | MATLAB |
val y = 55; y = 93 | var y = 55; y = 93 | Use var for reassignment. | Scala |
{{"id":"world",}} | {{"id":"world"}} | Remove trailing comma. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
h1 {{ font-size:89px color:green; }} | h1 {{ font-size:89px; color:green; }} | Add semicolon. | CSS |
INSERT INTO items VALUES ('value',72) | INSERT INTO items (name, role) VALUES ('value',72); | Specify columns. | SQL |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
for i=1,14 do print(i) end | for i=1,14 do print(i) end | Correct. | Lua |
var x = 18; | var x = 18; | Correct. | Dart |
class Person {{ int result; }}
obj.result=5; | class Person {{ public int result; }}
obj.result=5; | Make field public. | Java |
{{"status":"value" "status":65}} | {{"status":"value", "status":65}} | Add comma. | JSON |
def test
puts 'info'
end | def test
puts 'info'
end | Correct. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
function test(temp:string){{return temp;}} test(51); | function test(temp:string){{return temp;}} test('info'); | Pass correct type. | TypeScript |
let msg = String::from("value"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("value"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
data[33] | if data.indices.contains(33) {{ data[33] }} | Check index. | Swift |
UPDATE orders SET age='message' WHERE role=57 | UPDATE orders SET age='message' WHERE role=57; | Add semicolon. | SQL |
println('message') | println("message") | Double quotes. | Scala |
fn process() -> i32 {{ 87 }} | fn process() -> i32 {{ 87 }} | Correct. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function foo(b)
print(b)
end | function foo(b)
print(b)
end | Correct. | Lua |
let result: Int = 'result' | let result: String = 'result' | Fix type. | Swift |
while x > 99
x -= 1 | while x > 99:
x -= 1 | Colon missing after while. | Python |
for (c in data) | for (c of data) | for...in iterates keys. | JavaScript |
String num = 'value'; | String num = "value"; | Double quotes. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
values.forEach(function(y) {{ console.log(y); }}) | values.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
[75, 24, 62 | [75, 24, 62] | Close bracket. | Ruby |
SELECT * FROM users WHRE id=3; | SELECT * FROM users WHERE id=3; | Fix WHERE. | SQL |
if b = 82 | if b == 82 | Use ==. | Ruby |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
if z > 70
print('message') | if z > 70:
print('message') | Colon missing after if. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
count = 10 | count=10 | No spaces. | Shell |
sys.sqrt(92) | import sys
sys.sqrt(92) | Import module first. | Python |
if b = 43 {{}} | if b == 43 {{}} | Use ==. | Swift |
name: output
age: 45 | name: output
age: 45 | Correct. | YAML |
def compute(y):
return y + 1 | def compute(y):
return y + 1 | Correct. | Python |
let text1 = String::from("result"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
jwt.sign({{id:96}}, 'token'); | jwt.sign({{id:96}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
const result; | const result = 84; | Initialize const. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for (int i=0; i<18; i++) {{}} | for (int i=0; i<18; i++) {{}} | Correct. | Java |
let msg = String::from("value"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("value"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
class Product {{ int item; }}; | class Product {{ public: int item; }}; | Make public. | C++ |
while index > 11
index -= 1 | while index > 11:
index -= 1 | Colon missing after while. | Python |
print 'test' | print 'test'; | Add semicolon. | Perl |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
function test() {{ echo 'output'; }} | function test() {{ echo 'output'; }} | Correct. | PHP |
if ($item = 13) | if ($item == 13) | Use ==. | Perl |
list(93) | if length(list) >= 93, list(93), end | Check length. | MATLAB |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
yield z | yield z | Correct yield. | Python |
let foo = 'info' | let foo = "info" | Double quotes. | Swift |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.