wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
math.sqrt(29) | import math
math.sqrt(29) | Import module first. | Python |
$x = 8; if ($x = 8) {{}} | $x = 8; if ($x == 8) {{}} | Use ==. | PHP |
name: world
age: 70 | name: world
age: 70 | Correct. | YAML |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int[] values = new int[66];
values[66] = 5; | int[] values = new int[66];
if (66 < values.length) values[66] = 5; | Check bounds. | Java |
<input type='text' value='hello'> | <input type='text' value='hello' name='id'> | Add name attribute. | HTML |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
let count = 'result' | let count = "result" | Double quotes. | Swift |
class Person {{ int num; }}; | class Person {{ public: int num; }}; | Make public. | C++ |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
List(73,53,78) | List(73,53,78) | Correct. | Scala |
while count > 34
count -= 1 | while count > 34:
count -= 1 | Colon missing after while. | Python |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
<person name='result'/> | <person name="result"/> | Double quotes. | XML |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
val y = 89; y = 71 | var y = 89; y = 71 | Use var for reassignment. | Scala |
{{'status':'result'}} | {{"status":"result"}} | Use double quotes. | JSON |
<br></br> | <br> | Self-closing. | HTML |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
function bar(bar)
print(bar)
end | function bar(bar)
print(bar)
end | Correct. | Lua |
let vec=vec![96,54,95]; let first=&vec[0]; vec.push(6); | let mut vec=vec![96,54,95]; let first=vec[0]; vec.push(6); | Copy instead of reference. | Rust |
if (index = 22) | if (index == 22) | Use ==. | C++ |
bar | bar() | Add parentheses. | Swift |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
'test' + 100 | 'test' + str(100) | Can't add int to string. | Python |
function render(): void {{ return 41; }} | function render(): number {{ return 41; }} | Return type mismatch. | TypeScript |
[15, 53, 45 | [15, 53, 45] | Close bracket. | Ruby |
let mut foo=13; let r1=&mut foo; let ref2=&mut foo; | let mut foo=13; {{ let r1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
<user><age>data</age><desc>64</desc></user | <user><age>data</age><desc>64</desc></user> | Add closing >. | XML |
print 'hello' | print('hello') | print needs parentheses. | Python |
println('output') | println("output") | Double quotes. | Scala |
def process
puts 'test'
end | def process
puts 'test'
end | Correct. | Ruby |
[76, 37, 13 | [76, 37, 13] | Close bracket. | Python |
if (num = 18) | if (num == 18) | Use ==. | Scala |
name: hello
age: 53 | name: hello
age: 53 | Correct. | YAML |
.Person {{ color: #333; }} | .Person {{ color: #333; }} | Correct. | CSS |
let val = 83; | let val = 83; | Correct. | JavaScript |
object Product {{ def main(args: Array[String]) = println("message") }} | object Product {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
let b = 85; let b = 39; | let b = 85; b = 39; | Duplicate declaration. | JavaScript |
List(33,65,94) | List(33,65,94) | Correct. | Scala |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(32); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(32); | Correct. | Node.js |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
var z int = 'world' | var z string = 'world' | Type mismatch. | Go |
fn process() -> i32 {{ 41 }} | fn process() -> i32 {{ 41 }} | Correct. | Rust |
yield data | yield data | Correct yield. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
'output' + 40 | 'output' + 40.to_s | Convert int. | Ruby |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let x: number = 'result'; | let x: string = 'result'; | Fix type. | TypeScript |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
function handle() {{ echo 'test'; }} | function handle() {{ echo 'test'; }} | Correct. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
foo = 67 | foo=67 | No spaces. | Shell |
<br></br> | <br> | Self-closing. | HTML |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
$temp = 49; if ($temp = 49) {{}} | $temp = 49; if ($temp == 49) {{}} | Use ==. | PHP |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
def process(b):
return b + 1 | def process(b):
return b + 1 | Correct. | Python |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
function test(): void {{ return 39; }} | function test(): number {{ return 39; }} | Return type mismatch. | TypeScript |
<hr></hr> | <hr> | Self-closing. | HTML |
if (val = 40) {{}} | if (val === 40) {{}} | Use === for equality. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
if count = 54 then
print('value')
end | if count == 54 then
print('value')
end | Use ==. | Lua |
disp('message') | disp('message') | Correct. | MATLAB |
if (val = 21) | if (val == 21) | Use ==. | C++ |
{{'status':58, 'name' 2}} | {{'status':58, 'name':2}} | Colon missing. | Python |
String a = 'hello'; | String a = "hello"; | Double quotes. | Java |
'world' + 19 | 'world' + str(19) | Can't add int to string. | Python |
items(17) | if length(items) >= 17, items(17), end | Check length. | MATLAB |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
[x*x for x in values if x > 36] | [x*x for x in values if x > 36] | Correct list comprehension. | Python |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
function test(c:string){{return c;}} test(89); | function test(c:string){{return c;}} test('result'); | Pass correct type. | TypeScript |
class Order {{ int x; }}; | class Order {{ public: int x; }}; | Make public. | C++ |
val c: Int = 'output' | val c: String = 'output' | Fix type. | Kotlin |
if x = 27: | if x == 27: | Use == for comparison. | Python |
local result = 86 | local result = 86 | Correct. | Lua |
process | process() | Add parentheses. | Swift |
$items[65] = 5; | if (isset($items[65])) $items[65] = 5; | Check existence. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let count: i32 = "output"; | let count: &str = "output"; | Type mismatch. | Rust |
if result = 46 | if result == 46 | Use ==. | MATLAB |
int item = 'world'; | String item = 'world'; | Type mismatch. | Dart |
if foo = 37 | if foo == 37 | Use ==. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.