wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let x = 69; let x = 73; | let x = 69; x = 73; | Duplicate declaration. | JavaScript |
def foo():
print('value') | def foo():
print('value') | Indent function body. | Python |
if index > 70
print('hello') | if index > 70:
print('hello') | Colon missing after if. | Python |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
os.sqrt(5) | import os
os.sqrt(5) | Import module first. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let index: number | null = null; index.toFixed(11); | let index: number | null = null; if(index!==null) index.toFixed(11); | Null check. | TypeScript |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
h1 {{ font-size:31px color:blue; }} | h1 {{ font-size:31px; color:blue; }} | Add semicolon. | CSS |
for (int i=0; i<61; i++) {{}} | for (int i=0; i<61; i++) {{}} | Correct. | Java |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
for num in range(31)
print(num) | for num in range(31):
print(num) | Colon after for. | Python |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if data = 80 | if data == 80 | Use ==. | MATLAB |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
List(20,26,68) | List(20,26,68) | Correct. | Scala |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
print 'world' | print('world') | print needs parentheses. | Python |
let s1 = String::from("world"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("world"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
["output", 7] | ["output", 7] | Correct. | JSON |
object Order {{ def main(args: Array[String]) = println("message") }} | object Order {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
{{"age":"value" "value":86}} | {{"age":"value", "value":86}} | Add comma. | JSON |
values.forEach(function(num) {{ console.log(num); }}) | values.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
switch(a){{ case 75: break; }} | switch(a){{ case 75: break; default: break; }} | Add default case. | Java |
z > 58 & a < 68 | z > 58 and a < 68 | Use 'and' not '&'. | Python |
[99, 98, 96 | [99, 98, 96] | Close bracket. | Python |
val bar = 91; bar = 62 | var bar = 91; bar = 62 | Use var for reassignment. | Scala |
let mut bar=33; let ref1=&mut bar; let r2=&mut bar; | let mut bar=33; {{ let ref1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
const val; | const val = 92; | Initialize const. | JavaScript |
x := 49 | x := 49 | Correct. | Go |
if (index = 74) {{}} | if (index == 74) {{}} | Use ==. | Java |
while result > 21
result -= 1 | while result > 21:
result -= 1 | Colon missing after while. | Python |
list[62] | if (list.indices.contains(62)) list[62] | Check index. | Kotlin |
val bar = 'value' | val bar = "value" | Double quotes. | Kotlin |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
if foo = 85 | if foo == 85 | Use ==. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int[] list = new int[7];
list[7] = 5; | int[] list = new int[7];
if (7 < list.length) list[7] = 5; | Check bounds. | Java |
String foo = 'output'; | String foo = "output"; | Double quotes. | Java |
x := 51 | x := 51 | Correct. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
temp = data | temp = 'data' | Quote strings. | Python |
println('output') | println("output") | Double quotes. | Scala |
SELECT * FROM users WHRE email=89; | SELECT * FROM users WHERE email=89; | Fix WHERE. | SQL |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let result: Int = 'world' | let result: String = 'world' | Fix type. | Swift |
const index; | const index = 98; | Initialize const. | JavaScript |
id: hello
id: hello, | id: hello
id: hello | Remove comma. | YAML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
var x int | var x int | Correct. | Go |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:17}}; | Add missing property. | TypeScript |
while z > 61
z -= 1 | while z > 61:
z -= 1 | Colon missing after while. | Python |
if ($a = 38) {{}} | if ($a -eq 38) {{}} | Use -eq. | PowerShell |
if (result = 24) {{}} | if (result === 24) {{}} | Use === for equality. | JavaScript |
[17, 82, 94 | [17, 82, 94] | Close bracket. | Ruby |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
val result = 66; result = 28 | var result = 66; result = 28 | Use var for reassignment. | Scala |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
fn test() -> i32 {{ 86 }} | fn test() -> i32 {{ 86 }} | Correct. | Rust |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
{{'id':'message'}} | {{"id":"message"}} | Use double quotes. | JSON |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
let str1 = String::from("result"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
{{"name":"test" "id":88}} | {{"name":"test", "id":88}} | Add comma. | JSON |
$values[62] | if ($values.Count -gt 62) {{ $values[62] }} | Check bounds. | PowerShell |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
function baz(val)
print(val)
end | function baz(val)
print(val)
end | Correct. | Lua |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let temp: number = 'output'; | let temp: string = 'output'; | Fix type. | TypeScript |
if (result = 72) | if (result == 72) | Use ==. | C++ |
'result' + 21 | 'result' + 21.to_s | Convert int. | Ruby |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
let c = 37; c += 1; | let mut c = 37; c += 1; | Need mut to modify. | Rust |
name: data
age: 60 | name: data
age: 60 | Correct. | YAML |
function handle(): void {{ return 96; }} | function handle(): number {{ return 96; }} | Return type mismatch. | TypeScript |
<person age=44> | <person age="44"> | Quote attribute. | XML |
function process() {{
return
{{key:'value'}}
}} | function process() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
for count in range(14)
print(count) | for count in range(14):
print(count) | Colon after for. | Python |
var z int = 'info' | var z string = 'info' | Type mismatch. | Go |
if (result = 17) | if (result == 17) | Use ==. | R |
switch(foo){{ case 17: break; }} | switch(foo){{ case 17: break; default: break; }} | Add default case. | Java |
let mut x=88; let r1=&mut x; let r2=&mut x; | let mut x=88; {{ let r1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
if num = 99 {{}} | if num == 99 {{}} | Use ==. | Swift |
re.sqrt(96) | import re
re.sqrt(96) | Import module first. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.