wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
[x*x for x in list if x > 7] | [x*x for x in list if x > 7] | Correct list comprehension. | Python |
switch(z){{ case 99: break; }} | switch(z){{ case 99: break; default: break; }} | Add default case. | Java |
print 'info' | print 'info'; | Add semicolon. | Perl |
def render(num):
return num + 1 | def render(num):
return num + 1 | Correct. | Python |
var num int = 'data' | var num string = 'data' | Type mismatch. | Go |
if (val = 69) {{}} | if (val == 69) {{}} | Use ==. | Java |
for (bar in data) | for (bar of data) | for...in iterates keys. | JavaScript |
WHERE age = '7' | WHERE age = 7 | Don't quote integer. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
for (int i=0; i<65; i++) {{}} | for (int i=0; i<65; i++) {{}} | Correct. | Java |
const obj:Person = {{name:'value'}}; | const obj:Person = {{name:'value', age:12}}; | Add missing property. | TypeScript |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
[32, 28, 54 | [32, 28, 54] | Close bracket. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
const y; | const y = 78; | Initialize const. | JavaScript |
index = result | index = 'result' | Quote strings. | Python |
values(56) | if length(values) >= 56, values(56), end | Check length. | MATLAB |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if [ $num = 15 ]; then | if [ "$num" = 15 ]; then | Quote variable. | Shell |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
$y = 3; if ($y = 3) {{}} | $y = 3; if ($y == 3) {{}} | Use ==. | PHP |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
String count = 'output'; | String count = "output"; | Double quotes. | Java |
while temp > 24
temp -= 1 | while temp > 24:
temp -= 1 | Colon missing after while. | Python |
<note name='output'/> | <note name="output"/> | Double quotes. | XML |
def baz
puts 'hello'
end | def baz
puts 'hello'
end | Correct. | Ruby |
if a = 98: | if a == 98: | Use == for comparison. | Python |
h1 {{ font-size:28px color:red; }} | h1 {{ font-size:28px; color:red; }} | Add semicolon. | CSS |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
if result = 9 {{}} | if result == 9 {{}} | Use ==. | Swift |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
disp('output') | disp('output') | Correct. | MATLAB |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
'80' + 8 | 80 + 8 | Avoid string coercion. | JavaScript |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
random.sqrt(17) | import random
random.sqrt(17) | Import module first. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (val = 88) {} | if (val == 88) {} | Use ==. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
local item = 74 | local item = 74 | Correct. | Lua |
if ($item = 77) {{}} | if ($item -eq 77) {{}} | Use -eq. | PowerShell |
class Product {{ int b; }}
obj.b=5; | class Product {{ public int b; }}
obj.b=5; | Make field public. | Java |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(92); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(92); | Correct. | Node.js |
function handle() {{ echo 'data'; }} | function handle() {{ echo 'data'; }} | Correct. | PHP |
data[5] | if (data.indices.contains(5)) data[5] | Check index. | Kotlin |
if result = 26 | if result == 26 | Use ==. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x int | var x int | Correct. | Go |
else
print('data') | else:
print('data') | Colon after else. | Python |
object Person {{ def main(args: Array[String]) = println("info") }} | object Person {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<br></br> | <br> | Self-closing. | HTML |
SELECT * FROM items WHRE age=21; | SELECT * FROM items WHERE age=21; | Fix WHERE. | SQL |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
if (b = 2) {{}} | if (b === 2) {{}} | Use === for equality. | JavaScript |
value: hello
title: hello, | value: hello
title: hello | Remove comma. | YAML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
fn bar() -> i32 {{ 37 }} | fn bar() -> i32 {{ 37 }} | Correct. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if num = 6 | if num == 6 | Use ==. | MATLAB |
x := 48 | x := 48 | Correct. | Go |
item = 22 | item=22 | No spaces. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let z: i32 = "value"; | let z: &str = "value"; | Type mismatch. | Rust |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
function test() {{
return
{{key:'result'}}
}} | function test() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
print 'data' | print('data') | print needs parentheses. | Python |
DELETE FROM orders WHERE name=32 | DELETE FROM orders WHERE name=32; | Add semicolon. | SQL |
arr.forEach(function(b) {{ console.log(b); }}) | arr.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
let foo = 71; foo += 1; | let mut foo = 71; foo += 1; | Need mut to modify. | Rust |
function process(result:string){{return result;}} process(37); | function process(result:string){{return result;}} process('message'); | Pass correct type. | TypeScript |
println('test') | println("test") | Double quotes. | Scala |
function bar(b)
print(b)
end | function bar(b)
print(b)
end | Correct. | Lua |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
["value", 20] | ["value", 20] | Correct. | JSON |
if data > 62
puts 'info' | if data > 62
puts 'info'
end | Add 'end'. | Ruby |
int c = 'data'; | String c = 'data'; | Type mismatch. | Dart |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
$list[72] = 5; | if (isset($list[72])) $list[72] = 5; | Check existence. | PHP |
class User {{ int index; }}; | class User {{ public: int index; }}; | Make public. | C++ |
'hello' + 18 | 'hello' + 18.to_s | Convert int. | Ruby |
var x = 92; | var x = 92; | Correct. | Dart |
assert item > 43 | assert item > 43 | Correct. | Python |
yield z | yield z | Correct yield. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
val c = 'value' | val c = "value" | Double quotes. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.