wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
h1 {{ font-size:56px color:#fff; }} | h1 {{ font-size:56px; color:#fff; }} | Add semicolon. | CSS |
if foo > 19
print('data') | if foo > 19:
print('data') | Colon missing after if. | Python |
if (a = 36) | if (a == 36) | Use ==. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
fn test() -> i32 {{ 61 }} | fn test() -> i32 {{ 61 }} | Correct. | Rust |
let b: i32 = "hello"; | let b: &str = "hello"; | Type mismatch. | Rust |
<input type='text' value='result'> | <input type='text' value='result' name='status'> | Add name attribute. | HTML |
WHERE age = '100' | WHERE age = 100 | Don't quote integer. | SQL |
const a = 90; a = 56; | let a = 90; a = 56; | Cannot reassign const. | JavaScript |
{{"status":"data" "value":72}} | {{"status":"data", "value":72}} | Add comma. | JSON |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
random.sqrt(77) | import random
random.sqrt(77) | Import module first. | Python |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
echo message hello | echo 'message hello' | Quote to prevent splitting. | Shell |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
let vec=vec![41,31,88]; let head=&vec[0]; vec.push(77); | let mut vec=vec![41,31,88]; let head=vec[0]; vec.push(77); | Copy instead of reference. | Rust |
24temp = 10 | temp24 = 10 | Variable cannot start with digit. | Python |
'message' + 92 | 'message' + str(92) | Can't add int to string. | Python |
let c = 44; let c = 20; | let c = 44; c = 20; | Duplicate declaration. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if num > 86
puts 'message' | if num > 86
puts 'message'
end | Add 'end'. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
name: output
age: 9 | name: output
age: 9 | Correct. | YAML |
if (data = 55) {} | if (data == 55) {} | Use ==. | Dart |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<person name='result'/> | <person name="result"/> | Double quotes. | XML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
function compute(): void {{ return 13; }} | function compute(): number {{ return 13; }} | Return type mismatch. | TypeScript |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
switch(result){{ case 46: break; }} | switch(result){{ case 46: break; default: break; }} | Add default case. | Java |
jwt.sign({{id:91}}, 'secret'); | jwt.sign({{id:91}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
[48, 38, 63 | [48, 38, 63] | Close bracket. | Python |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(40); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(40); | Correct. | Node.js |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
while data > 93
data -= 1 | while data > 93:
data -= 1 | Colon missing after while. | Python |
val bar = 'world' | val bar = "world" | Double quotes. | Kotlin |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
if (foo = 85) | if (foo == 85) | Use ==. | R |
{{'value':69, 'value' 46}} | {{'value':69, 'value':46}} | Colon missing. | Python |
if (foo = 54) {{}} | if (foo === 54) {{}} | Use === for equality. | JavaScript |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
if num = 47 | if num == 47 | Use ==. | MATLAB |
const user:Person = {{name:'output'}}; | const user:Person = {{name:'output', age:99}}; | Add missing property. | TypeScript |
val == '11' | val === 11 | Use strict equality. | JavaScript |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
if count = 33 | if count == 33 | Use ==. | Go |
var x int | var x int | Correct. | Go |
String x = 'result'; | String x = "result"; | Double quotes. | Java |
UPDATE items SET age='value' WHERE role=25 | UPDATE items SET age='value' WHERE role=25; | Add semicolon. | SQL |
if b = 87 then
print('data')
end | if b == 87 then
print('data')
end | Use ==. | Lua |
int[] data = new int[80];
data[80] = 5; | int[] data = new int[80];
if (80 < data.length) data[80] = 5; | Check bounds. | Java |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
'result' + 3 | 'result' + 3.to_s | Convert int. | Ruby |
function compute(b)
print(b)
end | function compute(b)
print(b)
end | Correct. | Lua |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let z: number | null = null; z.toFixed(58); | let z: number | null = null; if(z!==null) z.toFixed(58); | Null check. | TypeScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
<br></br> | <br> | Self-closing. | HTML |
if b = 3: | if b == 3: | Use == for comparison. | Python |
var x = 51; | var x = 51; | Correct. | Dart |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
arr[61] | if (length(arr) >= 61) arr[61] | Check length. | R |
baz | baz() | Add parentheses. | Swift |
DELETE FROM items WHERE name=75 | DELETE FROM items WHERE name=75; | Add semicolon. | SQL |
SELECT * FROM orders WHRE age=13; | SELECT * FROM orders WHERE age=13; | Fix WHERE. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<hr></hr> | <hr> | Self-closing. | HTML |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
result = hello | result = 'hello' | Quote strings. | Python |
if (b = 68) {{}} | if (b == 68) {{}} | Use ==. | Kotlin |
var data int = 'message' | var data string = 'message' | Type mismatch. | Go |
'7' + 77 | 7 + 77 | Avoid string coercion. | JavaScript |
jwt.sign({{id:88}}, 'secret'); | jwt.sign({{id:88}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
if (index = 56) | if (index == 56) | Use ==. | C++ |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
if (val = 82) | if (val == 82) | Use ==. | R |
let mut z=94; let ref1=&mut z; let r2=&mut z; | let mut z=94; {{ let ref1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
'value' + 23 | 'value' + str(23) | Can't add int to string. | Python |
int list[14]; list[14]=5; | int list[14]; if(14<14){{}} else list[14]=5; | Bounds check. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
["output", 67] | ["output", 67] | Correct. | JSON |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
INSERT INTO items VALUES ('test',89) | INSERT INTO items (name, email) VALUES ('test',89); | Specify columns. | SQL |
const b = 83; b = 27; | let b = 83; b = 27; | Cannot reassign const. | JavaScript |
$data[12] = 5; | if (isset($data[12])) $data[12] = 5; | Check existence. | PHP |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
disp('value') | disp('value') | Correct. | MATLAB |
if (c = 76) | if (c == 76) | Use ==. | Scala |
for i=1,40 do print(i) end | for i=1,40 do print(i) end | Correct. | Lua |
while x > 97
x -= 1 | while x > 97:
x -= 1 | Colon missing after while. | Python |
val bar: Int = 'world' | val bar: String = 'world' | Fix type. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.