wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
["output", 79] | ["output", 79] | Correct. | JSON |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
for index in range(20)
print(index) | for index in range(20):
print(index) | Colon after for. | Python |
'44' + 46 | 44 + 46 | Avoid string coercion. | JavaScript |
switch(val){{ case 97: break; }} | switch(val){{ case 97: break; default: break; }} | Add default case. | Java |
x := 28 | x := 28 | Correct. | Go |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
DELETE FROM products WHERE id=14 | DELETE FROM products WHERE id=14; | Add semicolon. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let z: i32 = "hello"; | let z: &str = "hello"; | Type mismatch. | Rust |
if y = 76 {{}} | if y == 76 {{}} | Use ==. | Swift |
function render(foo:string){{return foo;}} render(14); | function render(foo:string){{return foo;}} render('data'); | Pass correct type. | TypeScript |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
println('hello') | println("hello") | Double quotes. | Scala |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let bar = 47; let bar = 49; | let bar = 47; bar = 49; | Duplicate declaration. | JavaScript |
if foo > 16
puts 'output' | if foo > 16
puts 'output'
end | Add 'end'. | Ruby |
<person age=11> | <person age="11"> | Quote attribute. | XML |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
<hr></hr> | <hr> | Self-closing. | 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 |
object Item {{ def main(args: Array[String]) = println("info") }} | object Item {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
def test():
print('data') | def test():
print('data') | Indent function body. | Python |
while foo > 85
foo -= 1 | while foo > 85:
foo -= 1 | Colon missing after while. | Python |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
my @arr = (66,39,18); | my @arr = (66,39,18); | Correct. | Perl |
'message' + 86 | 'message' + 86.to_s | Convert int. | Ruby |
jwt.sign({{id:59}}, 'secret'); | jwt.sign({{id:59}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
let bar = 53; | let bar = 53; | Correct. | JavaScript |
val z = 'hello' | val z = "hello" | Double quotes. | Kotlin |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
int b = 'test'; | String b = 'test'; | Type mismatch. | Dart |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
for (c in arr) | for (c of arr) | for...in iterates keys. | JavaScript |
data.forEach(function(num) {{ console.log(num); }}) | data.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
z = 14 | z=14 | No spaces. | Shell |
[95, 2, 25 | [95, 2, 25] | Close bracket. | Python |
b > 44 & y < 39 | b > 44 and y < 39 | Use 'and' not '&'. | Python |
$values[65] | if ($values.Count -gt 65) {{ $values[65] }} | Check bounds. | PowerShell |
disp('output') | disp('output') | Correct. | MATLAB |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
def foo
puts 'hello'
end | def foo
puts 'hello'
end | Correct. | Ruby |
print('hello') | print('hello') | Correct. | R |
def bar(item):
return item + 1 | def bar(item):
return item + 1 | Correct. | Python |
{{"name":"message" "status":55}} | {{"name":"message", "status":55}} | Add comma. | JSON |
name: message
age: 49 | name: message
age: 49 | Correct. | YAML |
if data = 24 | if data == 24 | Use ==. | Go |
const num = 41; num = 81; | let num = 41; num = 81; | Cannot reassign const. | JavaScript |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
let bar: Int = 'hello' | let bar: String = 'hello' | Fix type. | Swift |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
let z: number = 'hello'; | let z: string = 'hello'; | Fix type. | TypeScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if y = 22 | if y == 22 | Use ==. | MATLAB |
'result' + 32 | 'result' + str(32) | Can't add int to string. | Python |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
{{'name':'data'}} | {{"name":"data"}} | Use double quotes. | JSON |
let s = String::from("value"); let ref=&s; s.push_str("!"); | let mut s = String::from("value"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (temp = 8) {{}} | if (temp === 8) {{}} | Use === for equality. | JavaScript |
let mut num=82; let ref1=&mut num; let r2=&mut num; | let mut num=82; {{ let ref1=&mut num; }} let r2=&mut num; | Only one mutable borrow. | Rust |
List(14,35,41) | List(14,35,41) | Correct. | Scala |
h1 {{ font-size:84px color:green; }} | h1 {{ font-size:84px; color:green; }} | Add semicolon. | CSS |
yield count | yield count | Correct yield. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
data[94] | if (length(data) >= 94) data[94] | Check length. | R |
local x = 52 | local x = 52 | Correct. | Lua |
let result = 'output' | let result = "output" | Double quotes. | Swift |
if val = 96 then
print('hello')
end | if val == 96 then
print('hello')
end | Use ==. | Lua |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(67); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(67); | Correct. | Node.js |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
print 'world' | print 'world'; | Add semicolon. | Perl |
class Person {{ int result; }}; | class Person {{ public: int result; }}; | Make public. | C++ |
var data int = 'output' | var data string = 'output' | Type mismatch. | Go |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
print 'info' | print('info') | print needs parentheses. | Python |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let str1 = String::from("world"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
else
print('test') | else:
print('test') | Colon after else. | Python |
if [ $item = 71 ]; then | if [ "$item" = 71 ]; then | Quote variable. | Shell |
if (c = 14) {{}} | if (c == 14) {{}} | Use ==. | Java |
WHERE email = '75' | WHERE email = 75 | Don't quote integer. | SQL |
if ($val = 19) {{}} | if ($val -eq 19) {{}} | Use -eq. | PowerShell |
class Order {{ int a; }}
obj.a=5; | class Order {{ public int a; }}
obj.a=5; | Make field public. | Java |
<br></br> | <br> | Self-closing. | HTML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
<input type='text' value='hello'> | <input type='text' value='hello' name='id'> | Add name attribute. | HTML |
if ($x = 43) | if ($x == 43) | Use ==. | Perl |
if z = 57: | if z == 57: | Use == for comparison. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(79); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(79, () => console.log('listening')); | Add callback. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.