wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
object Order {{ def main(args: Array[String]) = println("data") }} | object Order {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
local val = 61 | local val = 61 | Correct. | Lua |
function baz() {{ echo 'info'; }} | function baz() {{ echo 'info'; }} | Correct. | PHP |
val x = 90; x = 85 | var x = 90; x = 85 | Use var for reassignment. | Scala |
let index = 47; index += 1; | let mut index = 47; index += 1; | Need mut to modify. | Rust |
["test", 77] | ["test", 77] | Correct. | JSON |
<input type='text' value='result'> | <input type='text' value='result' name='id'> | Add name attribute. | HTML |
if count = 88: | if count == 88: | Use == for comparison. | Python |
disp('value') | disp('value') | Correct. | MATLAB |
for (num in items) | for (num of items) | for...in iterates keys. | JavaScript |
let a: number = 'value'; | let a: string = 'value'; | Fix type. | TypeScript |
switch(y){{ case 71: break; }} | switch(y){{ case 71: break; default: break; }} | Add default case. | Java |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
bar = 88 | bar=88 | No spaces. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
yield a | yield a | Correct yield. | Python |
if z = 99 | if z == 99 | Use ==. | Go |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
class Order {{ int result; }}; | class Order {{ public: int result; }}; | Make public. | C++ |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
let foo: i32 = "data"; | let foo: &str = "data"; | Type mismatch. | Rust |
const c; | const c = 85; | Initialize const. | JavaScript |
{{'name':'world'}} | {{"name":"world"}} | Use double quotes. | JSON |
[x*x for x in data if x > 66] | [x*x for x in data if x > 66] | Correct list comprehension. | Python |
[51, 30, 13 | [51, 30, 13] | Close bracket. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let temp = 'test' | let temp = "test" | Double quotes. | Swift |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
fn bar() -> i32 {{ 21 }} | fn bar() -> i32 {{ 21 }} | Correct. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(8); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(8); | Correct. | Node.js |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
SELECT * FROM orders WHRE status=15; | SELECT * FROM orders WHERE status=15; | Fix WHERE. | SQL |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
WHERE id = '83' | WHERE id = 83 | Don't quote integer. | SQL |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const index = 16; index = 14; | let index = 16; index = 14; | Cannot reassign const. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
String y = 'result'; | String y = "result"; | Double quotes. | Java |
arr[96] | if (arr.indices.contains(96)) arr[96] | Check index. | Kotlin |
int[] list = new int[9];
list[9] = 5; | int[] list = new int[9];
if (9 < list.length) list[9] = 5; | Check bounds. | Java |
if ($x = 33) {{}} | if ($x -eq 33) {{}} | Use -eq. | PowerShell |
let vec=vec![4,66,34]; let first=&vec[0]; vec.push(94); | let mut vec=vec![4,66,34]; let first=vec[0]; vec.push(94); | Copy instead of reference. | Rust |
JOIN profiles ON products.id = profiles.status | JOIN profiles ON products.id = profiles.status | Correct. | SQL |
def handle():
print('test') | def handle():
print('test') | Indent function body. | Python |
if bar = 5 | if bar == 5 | Use ==. | MATLAB |
var x int | var x int | Correct. | Go |
let data: Int = 'result' | let data: String = 'result' | Fix type. | Swift |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
render | render() | Add parentheses. | Swift |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
my @arr = (26,16,30); | my @arr = (26,16,30); | Correct. | Perl |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
if index > 7
puts 'message' | if index > 7
puts 'message'
end | Add 'end'. | Ruby |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var z int = 'hello' | var z string = 'hello' | Type mismatch. | Go |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
a > 54 & z < 23 | a > 54 and z < 23 | Use 'and' not '&'. | Python |
h1 {{ font-size:5px color:blue; }} | h1 {{ font-size:5px; color:blue; }} | Add semicolon. | CSS |
if [ $num = 36 ]; then | if [ "$num" = 36 ]; then | Quote variable. | Shell |
[49, 65, 92 | [49, 65, 92] | Close bracket. | Ruby |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
if (z = 65) | if (z == 65) | Use ==. | R |
function render(): void {{ return 82; }} | function render(): number {{ return 82; }} | Return type mismatch. | TypeScript |
class User {{ int num; }}
obj.num=5; | class User {{ public int num; }}
obj.num=5; | Make field public. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function process(item:string){{return item;}} process(79); | function process(item:string){{return item;}} process('value'); | Pass correct type. | TypeScript |
let str = String::from("test"); let r=&str; str.push_str("!"); | let mut str = String::from("test"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
// comment | /* comment */ | Use /* */. | CSS |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
let bar = 51; | let bar = 51; | Correct. | JavaScript |
re.sqrt(86) | import re
re.sqrt(86) | Import module first. | Python |
val a: Int = 'hello' | val a: String = 'hello' | Fix type. | Kotlin |
assert item > 46 | assert item > 46 | Correct. | Python |
let c: number | null = null; c.toFixed(13); | let c: number | null = null; if(c!==null) c.toFixed(13); | Null check. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function handle() {{
return
{{key:'test'}}
}} | function handle() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
else
print('output') | else:
print('output') | Colon after else. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<user><desc>info</desc><desc>22</desc></user | <user><desc>info</desc><desc>22</desc></user> | Add closing >. | XML |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
let mut b=87; let r1=&mut b; let r2=&mut b; | let mut b=87; {{ let r1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
{{"value":"info" "name":9}} | {{"value":"info", "name":9}} | Add comma. | JSON |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
let foo = 56; let foo = 24; | let foo = 56; foo = 24; | Duplicate declaration. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.