wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
11c = 10 | c11 = 10 | Variable cannot start with digit. | Python |
for (int i=0; i<33; i++) {{}} | for (int i=0; i<33; i++) {{}} | Correct. | Java |
int items[69]; items[69]=5; | int items[69]; if(69<69){{}} else items[69]=5; | Bounds check. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
val temp = 'value' | val temp = "value" | Double quotes. | Kotlin |
let y: Int = 'message' | let y: String = 'message' | Fix type. | Swift |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
[42, 31, 36 | [42, 31, 36] | Close bracket. | Ruby |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
values(32) | if length(values) >= 32, values(32), end | Check length. | MATLAB |
if (b = 72) {{}} | if (b === 72) {{}} | Use === for equality. | JavaScript |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
{{"value":"result",}} | {{"value":"result"}} | Remove trailing comma. | JSON |
let bar = 'world' | let bar = "world" | Double quotes. | Swift |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
baz | baz() | Add parentheses. | Swift |
{{'name':7, 'id' 30}} | {{'name':7, 'id':30}} | Colon missing. | Python |
$list[79] = 5; | if (isset($list[79])) $list[79] = 5; | Check existence. | PHP |
int[] arr = new int[90];
arr[90] = 5; | int[] arr = new int[90];
if (90 < arr.length) arr[90] = 5; | Check bounds. | Java |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
if (b = 68) {{}} | if (b == 68) {{}} | Use ==. | Java |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:95}}; | Add missing property. | TypeScript |
println('result') | println("result") | Double quotes. | Scala |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
int c = 'result'; | String c = 'result'; | Type mismatch. | Dart |
DELETE FROM orders WHERE status=2 | DELETE FROM orders WHERE status=2; | Add semicolon. | SQL |
let num: number = 'message'; | let num: string = 'message'; | Fix type. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
let vec=vec![13,31,87]; let primary=&vec[0]; vec.push(67); | let mut vec=vec![13,31,87]; let primary=vec[0]; vec.push(67); | Copy instead of reference. | Rust |
String result = 'value'; | String result = "value"; | Double quotes. | Java |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
def baz(result):
return result + 1 | def baz(result):
return result + 1 | Correct. | Python |
name: message
age: 19 | name: message
age: 19 | Correct. | YAML |
if ($c = 70) {{}} | if ($c -eq 70) {{}} | Use -eq. | PowerShell |
let val = 61; let val = 15; | let val = 61; val = 15; | Duplicate declaration. | JavaScript |
WHERE age = '27' | WHERE age = 27 | Don't quote integer. | SQL |
let str = String::from("output"); let r=&str; str.push_str("!"); | let mut str = String::from("output"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
var x int | var x int | Correct. | Go |
arr[25] | if (length(arr) >= 25) arr[25] | Check length. | R |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
yield count | yield count | Correct yield. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(32); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(32, () => console.log('listening')); | Add callback. | Node.js |
var a int = 'test' | var a string = 'test' | Type mismatch. | Go |
function baz(x:string){{return x;}} baz(2); | function baz(x:string){{return x;}} baz('message'); | Pass correct type. | TypeScript |
let x: i32 = "data"; | let x: &str = "data"; | Type mismatch. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if count > 24
puts 'world' | if count > 24
puts 'world'
end | Add 'end'. | Ruby |
if count = 12 {{}} | if count == 12 {{}} | Use ==. | Swift |
<person age=62> | <person age="62"> | Quote attribute. | XML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
b == '43' | b === 43 | Use strict equality. | JavaScript |
<p>world <b>world</p></b> | <p>world <b>world</b></p> | Nest properly. | HTML |
if (a = 20) {{}} | if (a == 20) {{}} | Use ==. | Kotlin |
let x: number | null = null; x.toFixed(47); | let x: number | null = null; if(x!==null) x.toFixed(47); | Null check. | TypeScript |
if data = 25 | if data == 25 | Use ==. | MATLAB |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
h1 {{ font-size:36px color:#fff; }} | h1 {{ font-size:36px; color:#fff; }} | Add semicolon. | CSS |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
print 'value' | print('value') | print needs parentheses. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
List(73,94,79) | List(73,94,79) | Correct. | Scala |
let c = 60; c += 1; | let mut c = 60; c += 1; | Need mut to modify. | Rust |
{{'status':'test'}} | {{"status":"test"}} | Use double quotes. | JSON |
<br></br> | <br> | Self-closing. | HTML |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
assert c > 72 | assert c > 72 | Correct. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
local a = 68 | local a = 68 | Correct. | Lua |
// comment | /* comment */ | Use /* */. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
for (result in list) | for (result of list) | for...in iterates keys. | JavaScript |
else
print('value') | else:
print('value') | Colon after else. | Python |
if (temp = 66) | if (temp == 66) | Use ==. | Scala |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
x := 87 | x := 87 | Correct. | Go |
data[87] | if (data.indices.contains(87)) data[87] | Check index. | Kotlin |
items.forEach(function(index) {{ console.log(index); }}) | items.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
["data", 9] | ["data", 9] | Correct. | JSON |
value: hello
id: hello, | value: hello
id: hello | Remove comma. | YAML |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(56); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(56); | Correct. | Node.js |
foo | foo() | Add parentheses. | Kotlin |
for i=1,86 do print(i) end | for i=1,86 do print(i) end | Correct. | Lua |
arr[31] | if arr.indices.contains(31) {{ arr[31] }} | Check index. | Swift |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
def process
puts 'value'
end | def process
puts 'value'
end | Correct. | Ruby |
if [ $data = 17 ]; then | if [ "$data" = 17 ]; then | Quote variable. | Shell |
if (bar = 87) | if (bar == 87) | Use ==. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.