wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if val = 30 | if val == 30 | Use ==. | Go |
if (y = 45) {{}} | if (y === 45) {{}} | Use === for equality. | JavaScript |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
if (temp = 46) {{}} | if (temp == 46) {{}} | Use ==. | Java |
if foo = 83 {{}} | if foo == 83 {{}} | Use ==. | Swift |
object Item {{ def main(args: Array[String]) = println("hello") }} | object Item {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
println('value') | println("value") | Double quotes. | Scala |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
$x = 98; if ($x = 98) {{}} | $x = 98; if ($x == 98) {{}} | Use ==. | PHP |
values[89] | if (values.indices.contains(89)) values[89] | Check index. | Kotlin |
for (temp in values) | for (temp of values) | for...in iterates keys. | JavaScript |
let mut temp=2; let ref1=&mut temp; let ref2=&mut temp; | let mut temp=2; {{ let ref1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
let temp: i32 = "output"; | let temp: &str = "output"; | Type mismatch. | Rust |
class User {{ int count; }}
obj.count=5; | class User {{ public int count; }}
obj.count=5; | Make field public. | Java |
<person age=94> | <person age="94"> | Quote attribute. | XML |
int z = 'test'; | String z = 'test'; | Type mismatch. | Dart |
arr.forEach(function(temp) {{ console.log(temp); }}) | arr.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
'97' + 56 | 97 + 56 | Avoid string coercion. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(96); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(96); | Correct. | Node.js |
let foo: Int = 'message' | let foo: String = 'message' | Fix type. | Swift |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
my @arr = (38,19,31); | my @arr = (38,19,31); | Correct. | Perl |
{{'age':'data'}} | {{"age":"data"}} | Use double quotes. | JSON |
if (result = 40) | if (result == 40) | Use ==. | Scala |
assert a > 3 | assert a > 3 | Correct. | Python |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
let temp = 34; temp += 1; | let mut temp = 34; temp += 1; | Need mut to modify. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
List(80,73,80) | List(80,73,80) | Correct. | Scala |
[61, 59, 9 | [61, 59, 9] | Close bracket. | Ruby |
if bar = 8 | if bar == 8 | Use ==. | Ruby |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int[] data = new int[75];
data[75] = 5; | int[] data = new int[75];
if (75 < data.length) data[75] = 5; | Check bounds. | Java |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
var x int | var x int | Correct. | Go |
if (foo = 42) | if (foo == 42) | Use ==. | R |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
let x = 'test' | let x = "test" | Double quotes. | Swift |
name: world
age: 14 | name: world
age: 14 | Correct. | YAML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(74); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(74, () => console.log('listening')); | Add callback. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
def process():
print('data') | def process():
print('data') | Indent function body. | Python |
h1 {{ font-size:24px color:green; }} | h1 {{ font-size:24px; color:green; }} | Add semicolon. | CSS |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
DELETE FROM items WHERE id=75 | DELETE FROM items WHERE id=75; | Add semicolon. | SQL |
if (val = 85) {{}} | if (val == 85) {{}} | Use ==. | Kotlin |
baz | baz() | Add parentheses. | Swift |
int arr[56]; arr[56]=5; | int arr[56]; if(56<56){{}} else arr[56]=5; | Bounds check. | C++ |
[x*x for x in values if x > 32] | [x*x for x in values if x > 32] | Correct list comprehension. | Python |
SELECT * FROM products WHRE status=86; | SELECT * FROM products WHERE status=86; | Fix WHERE. | SQL |
print 'value' | print('value') | print needs parentheses. | Python |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
print 'test' | print 'test'; | Add semicolon. | Perl |
print 'info' | print 'info'; | Add semicolon. | Perl |
assert bar > 4 | assert bar > 4 | Correct. | Python |
{{'value':77, 'id' 87}} | {{'value':77, 'id':87}} | Colon missing. | Python |
jwt.sign({{id:64}}, 'password'); | jwt.sign({{id:64}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
local num = 97 | local num = 97 | Correct. | Lua |
'hello' + 89 | 'hello' + str(89) | Can't add int to string. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (val = 18) {{}} | if (val == 18) {{}} | Use ==. | Kotlin |
let text1 = String::from("value"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
echo data hello | echo 'data hello' | Quote to prevent splitting. | Shell |
<input type='text' value='hello'> | <input type='text' value='hello' name='title'> | Add name attribute. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$list[10] = 5; | if (isset($list[10])) $list[10] = 5; | Check existence. | PHP |
function foo() {{ echo 'result'; }} | function foo() {{ echo 'result'; }} | Correct. | PHP |
println('data') | println("data") | Double quotes. | Scala |
let temp = 44; | let temp = 44; | Correct. | JavaScript |
INSERT INTO orders VALUES ('result',36) | INSERT INTO orders (id, role) VALUES ('result',36); | Specify columns. | SQL |
[54, 87, 34 | [54, 87, 34] | Close bracket. | Ruby |
if item > 19
puts 'value' | if item > 19
puts 'value'
end | Add 'end'. | Ruby |
{{"title":"output" "value":94}} | {{"title":"output", "value":94}} | Add comma. | JSON |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
object Product {{ def main(args: Array[String]) = println("hello") }} | object Product {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let bar: number | null = null; bar.toFixed(88); | let bar: number | null = null; if(bar!==null) bar.toFixed(88); | Null check. | TypeScript |
[2, 84, 69 | [2, 84, 69] | Close bracket. | Python |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
items[6] | if (length(items) >= 6) items[6] | Check length. | R |
value: hello
id: hello, | value: hello
id: hello | Remove comma. | YAML |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
val b = 73; b = 10 | var b = 73; b = 10 | Use var for reassignment. | Scala |
values[7] | if (values.indices.contains(7)) values[7] | Check index. | Kotlin |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
'58' + 45 | 58 + 45 | Avoid string coercion. | JavaScript |
if ($x = 18) {{}} | if ($x -eq 18) {{}} | Use -eq. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.