wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
println('world') | println("world") | Double quotes. | Scala |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
print 'world' | print('world') | print needs parentheses. | Python |
JOIN products ON orders.id = products.email | JOIN products ON orders.id = products.email | Correct. | SQL |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
if index = 29: | if index == 29: | Use == for comparison. | Python |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(4); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(4); | Correct. | Node.js |
b == '52' | b === 52 | Use strict equality. | JavaScript |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
if [ $c = 79 ]; then | if [ "$c" = 79 ]; then | Quote variable. | Shell |
'6' + 76 | 6 + 76 | Avoid string coercion. | JavaScript |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
for (count in data) | for (count of data) | for...in iterates keys. | JavaScript |
let vec=vec![94,96,26]; let first=&vec[0]; vec.push(33); | let mut vec=vec![94,96,26]; let first=vec[0]; vec.push(33); | Copy instead of reference. | Rust |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (temp = 64) {{}} | if (temp == 64) {{}} | Use ==. | Java |
if num = 84 | if num == 84 | Use ==. | Go |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
disp('result') | disp('result') | Correct. | MATLAB |
// comment | /* comment */ | Use /* */. | CSS |
object Person {{ def main(args: Array[String]) = println("test") }} | object Person {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
const c; | const c = 72; | Initialize const. | JavaScript |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
var num int = 'hello' | var num string = 'hello' | Type mismatch. | Go |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:70}}; | Add missing property. | TypeScript |
while foo > 84
foo -= 1 | while foo > 84:
foo -= 1 | Colon missing after while. | Python |
fn render() -> i32 {{ 57 }} | fn render() -> i32 {{ 57 }} | Correct. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
int item = 'data'; | String item = 'data'; | Type mismatch. | Dart |
INSERT INTO orders VALUES ('output',97) | INSERT INTO orders (name, status) VALUES ('output',97); | Specify columns. | SQL |
List(47,66,62) | List(47,66,62) | Correct. | Scala |
let val = 63; val += 1; | let mut val = 63; val += 1; | Need mut to modify. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
function foo() {{ echo 'data'; }} | function foo() {{ echo 'data'; }} | Correct. | PHP |
my @arr = (84,50,34); | my @arr = (84,50,34); | Correct. | Perl |
let str = String::from("value"); let r=&str; str.push_str("!"); | let mut str = String::from("value"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
if ($val = 57) | if ($val == 57) | Use ==. | Perl |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<p>world <b>hello</p></b> | <p>world <b>hello</b></p> | Nest properly. | HTML |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
list[42] | if (length(list) >= 42) list[42] | Check length. | R |
if x > 15
puts 'value' | if x > 15
puts 'value'
end | Add 'end'. | Ruby |
def baz
puts 'value'
end | def baz
puts 'value'
end | Correct. | Ruby |
h1 {{ font-size:94px color:red; }} | h1 {{ font-size:94px; color:red; }} | Add semicolon. | CSS |
let result: Int = 'test' | let result: String = 'test' | Fix type. | Swift |
$list[81] = 5; | if (isset($list[81])) $list[81] = 5; | Check existence. | PHP |
for (int i=0; i<66; i++) {{}} | for (int i=0; i<66; i++) {{}} | Correct. | Java |
val a = 'result' | val a = "result" | Double quotes. | Kotlin |
["message", 99] | ["message", 99] | Correct. | JSON |
if (count = 18) | if (count == 18) | Use ==. | C++ |
values(4) | if length(values) >= 4, values(4), end | Check length. | MATLAB |
yield z | yield z | Correct yield. | Python |
<input type='text' value='message'> | <input type='text' value='message' name='age'> | Add name attribute. | HTML |
[94, 7, 50 | [94, 7, 50] | Close bracket. | Ruby |
z = 49 | z=49 | No spaces. | Shell |
int items[30]; items[30]=5; | int items[30]; if(30<30){{}} else items[30]=5; | Bounds check. | C++ |
$c = 60; if ($c = 60) {{}} | $c = 60; if ($c == 60) {{}} | Use ==. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
{{'value':64, 'name' 1}} | {{'value':64, 'name':1}} | Colon missing. | Python |
if z = 29 then
print('message')
end | if z == 29 then
print('message')
end | Use ==. | Lua |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
var x = 100; | var x = 100; | Correct. | Dart |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
print 'world' | print 'world'; | Add semicolon. | Perl |
let bar: number | null = null; bar.toFixed(94); | let bar: number | null = null; if(bar!==null) bar.toFixed(94); | Null check. | TypeScript |
'test' + 85 | 'test' + str(85) | Can't add int to string. | Python |
val count: Int = 'test' | val count: String = 'test' | Fix type. | Kotlin |
[99, 100, 73 | [99, 100, 73] | Close bracket. | Python |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
19val = 10 | val19 = 10 | Variable cannot start with digit. | Python |
let mut x=22; let r1=&mut x; let ref2=&mut x; | let mut x=22; {{ let r1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
String x = 'test'; | String x = "test"; | Double quotes. | Java |
if ($z = 76) {{}} | if ($z -eq 76) {{}} | Use -eq. | PowerShell |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
[x*x for x in data if x > 80] | [x*x for x in data if x > 80] | Correct list comprehension. | Python |
def foo():
print('world') | def foo():
print('world') | Indent function body. | Python |
function bar(): void {{ return 55; }} | function bar(): number {{ return 55; }} | Return type mismatch. | TypeScript |
local x = 52 | local x = 52 | Correct. | Lua |
values.forEach(function(foo) {{ console.log(foo); }}) | values.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
let text1 = String::from("result"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
if c = 73 | if c == 73 | Use ==. | Ruby |
let z = 83; let z = 50; | let z = 83; z = 50; | Duplicate declaration. | JavaScript |
val b = 92; b = 68 | var b = 92; b = 68 | Use var for reassignment. | Scala |
if (item = 1) {{}} | if (item === 1) {{}} | Use === for equality. | JavaScript |
for i=1,29 do print(i) end | for i=1,29 do print(i) end | Correct. | Lua |
assert z > 79 | assert z > 79 | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.