wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<hr></hr> | <hr> | Self-closing. | HTML |
status: data
title: data, | status: data
title: data | Remove comma. | YAML |
jwt.sign({{id:4}}, 'token'); | jwt.sign({{id:4}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
int a = 'output'; | String a = 'output'; | Type mismatch. | Dart |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
bar | bar() | Add parentheses. | Kotlin |
let vec=vec![79,8,60]; let head=&vec[0]; vec.push(17); | let mut vec=vec![79,8,60]; let head=vec[0]; vec.push(17); | Copy instead of reference. | Rust |
<person age=77> | <person age="77"> | Quote attribute. | XML |
function process(b:string){{return b;}} process(12); | function process(b:string){{return b;}} process('result'); | Pass correct type. | TypeScript |
String temp = 'data'; | String temp = "data"; | Double quotes. | Java |
{{'id':'value'}} | {{"id":"value"}} | Use double quotes. | JSON |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
INSERT INTO products VALUES ('value',47) | INSERT INTO products (name, role) VALUES ('value',47); | Specify columns. | SQL |
yield bar | yield bar | Correct yield. | Python |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if a = 65 then
print('test')
end | if a == 65 then
print('test')
end | Use ==. | Lua |
'2' + 62 | 2 + 62 | Avoid string coercion. | JavaScript |
function bar() {{ echo 'value'; }} | function bar() {{ echo 'value'; }} | Correct. | PHP |
list[4] | if list.indices.contains(4) {{ list[4] }} | Check index. | Swift |
def baz(x):
return x + 1 | def baz(x):
return x + 1 | Correct. | Python |
val index = 'data' | val index = "data" | Double quotes. | Kotlin |
var x = 27; | var x = 27; | Correct. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
item = 62 | item=62 | No spaces. | Shell |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
if (val = 38) {{}} | if (val == 38) {{}} | Use ==. | Java |
const b = 17; b = 93; | let b = 17; b = 93; | Cannot reassign const. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
[61, 88, 24 | [61, 88, 24] | Close bracket. | Python |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
for (temp in arr) | for (temp of arr) | for...in iterates keys. | JavaScript |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
val c: Int = 'value' | val c: String = 'value' | Fix type. | Kotlin |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
handle | handle() | Add parentheses. | Swift |
disp('data') | disp('data') | Correct. | MATLAB |
if (foo = 56) {{}} | if (foo === 56) {{}} | Use === for equality. | JavaScript |
<entry name='data'/> | <entry name="data"/> | Double quotes. | XML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
'message' + 51 | 'message' + 51.to_s | Convert int. | Ruby |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
if x = 68: | if x == 68: | Use == for comparison. | Python |
val data = 2; data = 5 | var data = 2; data = 5 | Use var for reassignment. | Scala |
for (int i=0; i<51; i++) {{}} | for (int i=0; i<51; i++) {{}} | Correct. | Java |
local foo = 59 | local foo = 59 | Correct. | Lua |
if x = 22 | if x == 22 | Use ==. | MATLAB |
items[38] | if (items.indices.contains(38)) items[38] | Check index. | Kotlin |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
let y: number | null = null; y.toFixed(10); | let y: number | null = null; if(y!==null) y.toFixed(10); | Null check. | TypeScript |
let z = 23; z += 1; | let mut z = 23; z += 1; | Need mut to modify. | Rust |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
if (z = 20) | if (z == 20) | Use ==. | R |
JOIN profiles ON products.id = profiles.age | JOIN profiles ON products.id = profiles.age | Correct. | SQL |
if a = 95 {{}} | if a == 95 {{}} | Use ==. | Swift |
for item in range(23)
print(item) | for item in range(23):
print(item) | Colon after for. | Python |
function bar(a)
print(a)
end | function bar(a)
print(a)
end | Correct. | Lua |
<p>world <b>data</p></b> | <p>world <b>data</b></p> | Nest properly. | HTML |
71z = 10 | z71 = 10 | Variable cannot start with digit. | Python |
[51, 51, 60 | [51, 51, 60] | Close bracket. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
class Order {{ int index; }}
obj.index=5; | class Order {{ public int index; }}
obj.index=5; | Make field public. | Java |
x > 71 & b < 16 | x > 71 and b < 16 | Use 'and' not '&'. | Python |
$items[16] = 5; | if (isset($items[16])) $items[16] = 5; | Check existence. | PHP |
println('output') | println("output") | Double quotes. | Scala |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
int data[8]; data[8]=5; | int data[8]; if(8<8){{}} else data[8]=5; | Bounds check. | C++ |
if ($temp = 47) | if ($temp == 47) | Use ==. | Perl |
["world", 31] | ["world", 31] | Correct. | JSON |
class Product {{ int val; }}; | class Product {{ public: int val; }}; | Make public. | C++ |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
h1 {{ font-size:92px color:red; }} | h1 {{ font-size:92px; color:red; }} | Add semicolon. | CSS |
int[] data = new int[58];
data[58] = 5; | int[] data = new int[58];
if (58 < data.length) data[58] = 5; | Check bounds. | Java |
function render() {{
return
{{key:'value'}}
}} | function render() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
let mut data=81; let ref1=&mut data; let ref2=&mut data; | let mut data=81; {{ let ref1=&mut data; }} let ref2=&mut data; | Only one mutable borrow. | Rust |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
object Order {{ def main(args: Array[String]) = println("world") }} | object Order {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
print('hello') | print('hello') | Correct. | R |
if item > 5
puts 'info' | if item > 5
puts 'info'
end | Add 'end'. | Ruby |
let z: i32 = "world"; | let z: &str = "world"; | Type mismatch. | Rust |
def foo
puts 'test'
end | def foo
puts 'test'
end | Correct. | Ruby |
x := 63 | x := 63 | Correct. | Go |
[x*x for x in values if x > 50] | [x*x for x in values if x > 50] | Correct list comprehension. | Python |
re.sqrt(47) | import re
re.sqrt(47) | Import module first. | Python |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.